Re: Design note: Replacing the preprocessor with reflection and generation #737
rmerriam
started this conversation in
Suggestions
Replies: 2 comments
-
Yes: #625 (comment). |
Beta Was this translation helpful? Give feedback.
0 replies
-
What defines consteval { // run this block of code at compile time
if WIN32 != "" || WinVersion > 0 {
-> { use this code }
} else {
-> { use that code }
}
} Are these supposed to be compiler flags? One is a string and the other is a number. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the late 90s, I was working on the Windows version of a project that would also be implemented in Linux and Novell (!!). Thus, I faced the problem of this Design Note. Besides, I always hated the #if #else if tests in code as a distraction.
I created a directory and header file:
include\windows\os.h
. All the calls to the OS were wrapped in inline functions, which called the OS version. The source includedos.h
while the compiler was directed to use the directory to obtain the header file. I don't recall if there was a source file that needed compilation. Likely not, since most calls were simply wrappers.The Novell guys followed this pattern with `include\novell\os.h'. A few years later, I looked at the source. The Linux guys didn't like it and reverted to the preprocessor usage.
This small project had no GUI, so this may not work for other projects. I comment to stimulate other thoughts and ask:
Can we do this external to the code so it isn't sprinkled with
Beta Was this translation helpful? Give feedback.
All reactions