Category : preprocessor

I have a macro that automatically includes a header file based on a preprocessor definition, #define MACRO_SCENARIO ScenarioFUN which will then generate: #include ScenarioFUN.h. This works well, however, I would also like to automatically generate the conditional preprocessor ifdef guard definition that conditionally compiles ScenarioFUN.cpp. This problem could be easily solved by forcing the user ..

Read more

I have a class that allows for dynamically setting specific values. It has multiple constructors in the following way: class Property { enum PropertyType { INT32, UINT32, UINT64, OBJECTSIZE, … }; public: Property(int32_t value_) : type(INT32), value(value_) {} Property(uint32_t value_) : type(UINT32), value(value_) {} Property(uint64_t value_) : type(UINT64), value(value_) {} Property(size_t value_) : type(OBJECTSIZE), value(value_) ..

Read more

I found the following code here: class Cipher { … }; #define TC_TRIAL(NAME, BLOCK_SIZE, KEY_SIZE) class TC_JOIN (Cipher,NAME) : public Cipher { … } TC_CIPHER (AES, 16, 32); I am aware that this is a macro and that (NAME, BLOCK_SIZE, KEY_SIZE) are additional parameters, but after the preprocessor replaces any corresponding occurrences of the parameters ..

Read more

I am creating a VST(virtual instrument) program in cpp and I have an array of structs that represent various parameters in my program: const FloatParam_Properties FloatParamProps[NUM_FLOAT_PARAMS] = { //Frequency {"BaseFreq", "Base Freq", 0.0, 20.0, 5.0, 0.6}, //0 {"FreqDelta", "Freq Delta", -20.0, 20.0, 0.0, 0.6}, //1 … //Wave {"OscSelect", "Wave form", 0.0, 3.0, 0.0, 1.0}, //9 ..

Read more

Consider the following simple C/C++ example: #define FOO … #ifdef FOO bar++; #endif OK, now I would like to fit that (any any other similar) conditional into one line for the code readability sake (the code has tens of single-line statements that all need to be conditional each depending on different define). Something that, when ..

Read more