this post was submitted on 28 Jun 2023
6 points (100.0% liked)
Programming
43 readers
1 users here now
This magazine is dedicated to discussions on programming languages, software development, and coding. Whether you are a beginner programmer or an experienced developer, this is the place for you. Here you can share your knowledge, ask questions, and engage in discussions on topics such as coding languages, software engineering, web development, and more. From the latest trends and frameworks to tips and tricks for debugging, this category covers a wide range of topics related to programming.
founded 2 years ago
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Between those two options, use the preprocessor directives; otherwise go with @alejandro's sugestion. The latter solution incurs a constant cost at runtime and includes code in the executable that should never be run. Preprocessor directives would completely omit the respective feature's code preventing any possibility of access, without them the feature could actually be enabled via memory scanners (something I myself have abused).
I'm no C expert, so take this with a grain of salt, but wouldn't any reasonable optimizing compiler remove the constant check at compile-time?
Of course, this is not guaranteed and depends on the compiler flags, so preproc should be preferred if compile-time is desired.