Conditional compilation depending on the framework version in C#
Are there any preprocessor symbols which allow something like #if CLR_AT_LEAST_3.5 // use ReaderWriterLockSlim #else // use ReaderWriterLock #endif or some other way to do this? ...
Are there any preprocessor symbols which allow something like #if CLR_AT_LEAST_3.5 // use ReaderWriterLockSlim #else // use ReaderWriterLock #endif or some other way to do this? ...
Is there a way to include an entire text file as a string in a C program at compile-time? something like: file.txt: This is a little text file main.c: #include <stdio.h> int main(void) { #blackmagicinclude("file.txt", content) /* equiv: char[] content = "This is\na little\ntext file"; */ printf("%s", content); } o...
I have a chunk of code where it appears that a variable is changing at the end of a pre-processor block of code. int initialKeyCount; #if(DEBUG) // int initialKeyCount = _root.CountAllKeys(); initialKeyCount = 20000; #endif currNode = currNode.EnsureDegreeKeysPresent(parent); //initialKeyCount = 19969 here #if(DEBUG...
In C# 3.0, I have a property which is suppose to contain the version of the class. The version number is simply the date and time of compilation. Right now, I have the following code: public DateTime Version { get { return DateTime.UtcNow; } } Obviously, this is wrong since this property returns me the current date and time. So, i...
Does anyone know of a Python equivalent for FMPP the text file preprocessor? Follow up: I am reading the docs and looking at the examples for the suggestions given. Just to expand. My usage of FMPP is to read in a data file (csv) and use multiple templates depending on that data to create multi page reports in html all linked to a main ...
For instance, is the following possible: #define definer(x) #define #x? Thanks. ...
I would like to detect whether the OS I'm compiling on is Windows. Is there a simple macro I can check to verify that? ...
If I write a #define that performs an operation using other preprocessor constants, is the final value computed each time the macro appears at runtime? Does this depend on optimizations in the compiler, or is it covered under a standard? Example: #define EXTERNAL_CLOCK_FREQUENCY 32768 #define TIMER_1_S EXTERNAL_CLO...
Hi folks! I use a parser generator here, that unfortunately insists on putting a #include <some/file.h> at the top of every generated source file. The header has since long been renamed. While it is no problem forcing the compiler (gcc) to use the new header with -include new/header.h, removing the above directive from every generate...
I'm playing around with gmock and noticed it contains this line: #include <tuple> I would have expected tuple.h. When is it okay to exclude the extension, and does it give the directive a different meaning? ...
For the code: int i; gcc preprocessor outputs: int i; How to force it to preserve whitespace? I call preprocessor with: gcc -E somefile.c command. ...
I am looking for a way to remove all uses of a particular class, including the class itself, at compile time. Basically a form of pre-processing, but I'd like to do it without having to surround all the instances with #ifdebug ... #endif. Is there any ant-based tool out there that can do this? If not, can anyone point me in the right di...
Hi, I have the following problem. I want to include a multi-line textfile as #define, i.e. what I need is a constant that stores the value of the text file. Example: File 'f.txt': This\nis\n\nsome\ntext and I want to initialize a constant (at compile time) in the style of #define txtfile "This\nis\na\ntextfile" where the string "Thi...
Why wont this work? 0. #define CONCAT(x, y) x ## y 1. 2. #define VAR_LINE(x) \ 3. int CONCAT(_anonymous, __LINE__) = x 4. 5. #define VAR_LINE2(x) \ 6. int _anonymous ## x = 1 7. 8. int main() 9. { 10. VAR_LINE(1); 11. VAR_LINE(1); 12. VAR_LINE(1); 13. VAR_LINE2(__LINE__); 14. } The result from the a...
I believe, that the usage of preprocessor directives like #if UsingNetwork is bad OO practice - other coworkers do not. I think, when using an IoC container (e.g. Spring), components can be easily configured if programmed accordingly. In this context either a propery IsUsingNetwork can be set by the IoC container or, if the "using networ...
Is there a way to do the following preprocessor directives in Python? #if DEBUG < do some code > #else < do some other code > #endif ...
I need to create a demo version of an existing large application consisting of multiple projects. I'd like to use the existing projects, and just neuter the functionality via preprocessor directives #if DEMO mycode.NeuterNow(); #endif We are building our app using MSBuild, and I'd ideally use something along the lines of: MSBui...
Original Question What I'd like is not a standard C pre-processor, but a variation on it which would accept from somewhere - probably the command line via -DNAME1 and -UNAME2 options - a specification of which macros are defined, and would then eliminate dead code. It may be easier to understand what I'm after with some examples: #ifd...
Please look at the following file: (it is a complete file) #ifndef TEES_ALGORITHM_LIBRARY_WRAPPER_H #define TEES_ALGORITHM_LIBRARY_WRAPPER_H #ifdef _TEES_COMPILE_AS_LIB #include <dfa\Includes\DFC_algorithms.hpp> #include <DFA\FuzzyClassifier\FuzzyAlgorithmIntialization\InitFuzzyAlgorithm.hpp> typedef teesalgorithm::tees_fuzzy_algorithm...
I am not understanding this question...can you tell me what to do in a short message...or give me some links to search....please, it's urgent You are required to implement a C preprocessor. The Preprocessor is to be implemented as a command-line tool, the input to which is a C source file (.c extension) and the output is the preprocesse...