preprocessor

macro in loops?

for(x;x<crap;x++){ macro(x,y); } how is this handled by preprocessor? is the loop unrolled or something else? ...

Mixing variables and integer constants in the Boost Preprocessor

I am using BOOST_PP for to do precompile computations in the preprocessor. I am focusing on an application where code size is extremely important to me. (So please don't say the compiler should or usually does that, I need to control what is performed at compile time and what code is generated). However, I want to be able to use the same...

C++ preprocessor concatenation

I have a function build with function pointers. I think it might be faster to try to exchange this function with pre processor macro. At least, I would like to try out the macro so I can measure if it generates faster code. It's more or less like this: typedef int (Item::*GetterPtr)(void)const; typedef void (Item::*SetterPtr)(int); vo...

White-box testing - friends or preprocessor?

So, imagine we have a class like this class Testee { public: void Func() private: void auxFunc() }; and we want to do white-box unit-testing on it. Which do you think is a better approach? To declare the tester class a friend of the testee class? Or use the preprocessor like this: class Testee { public: void Fu...

Simplifying compilation with each of a list of options

I've got a list of definitions: MASTER, SLAVE0, SLAVE1, ... SLAVE9 to control which array of audio data is programmed into a microcontroller. The micro can hold no more than one sound file, so I have included the following definitions at the top of my main.c file: #define MASTER #define SLAVE0 #define SLAVE1 .... #define SLAVE9 Then...

Built-in preprocessor token to detect iPhone app target

Hi, I need to set up correctly the FIRM ID for my app(according to target).For example I wrote in my Distribution.h the following lines: #define X_FIRM_ID @"X" #define XX_FIRM_ID @"XX" #define FIRM_ID XX_FIRM_ID For each build that I made I must manually change the FIRM_ID.I want to this automatically, just like I do for Default.png...

GCC preprocessor

Possible Duplicate: gcc preprocessor Is there a gcc option to make the gcc preprocessor generate C source code but filter out irrelevant source code? For example, a C file has #define switch to define for many different platforms. I'm only intersted in one platform, so I want the C preprocessor to filter out unrelated code. Do...

I dont want to preprocess specific macros.It should not replace it with its value.Is it possible?

Example = #define a 100 #define b 200 main() { int c=a+b; } After preprocrssing Output- #define a 100 main() { int c=a+200; } ...

Preprocessor logging statements in java

for example I want to replace before compilation: #debug("${enclosing_method} this is debug message for " + userName) with: if (log.isDebugEnabled()) { log.debug("<real method name> this is debug message for " + userName); } ...

Is it possible to add a reference in a C# project depending on the value of a conditional compilation symbol (preprocessor constant)?

Hello, I am developing a library which can be compiled for two different technologies. Basically, the users of the library should be able to compile the solution either for the Unity3D game engine or the NeoAxis game engine. The problem is: while the library is ready for the conditional compilation (#if UNITY using ... #endif, etc.), I c...

C++ Constant preprocessor macros and templates

So say I have the following very simple macro, along with a bit of code to output it: #define SIMPLEHASH(STRING) STRING[1] + STRING[2] + STRING[3] std::cout << SIMPLEHASH("Blah"); This outputs 309, and if you view the assembly you can see: 00131094 mov ecx,dword ptr [__imp_std::cout (132050h)] 0013109A push 135h ...

Problem with organizing files in Visual C++ project

Hi to all, I'm writing a project in Visual C++ 2010 Express edition. Everything was fine before i tried to add new source file in the project. Then when i tried to include one of the header files the compiler said that the class declared in this header is not found in other source file which includes the same header file. This is out...

How does C# compile the code with #if preprocessor directive?

Hi I wonder how to compiler compile my code if i using #if directive inside my code. I would like to create special version of my application (commercial demo version) and I want to limit the functionality of my application. I would rather avoid the obfuscation and just don't want to add all my compiled code to executable file. I need so...

C++ preprocessor

I'd rewritten a simple C++ program using unix as a variable name. But the program compilation failed. #include <iostream> int main() { int unix = 1; return 0; } After searching a lot on the internet I got to this website which helped me by saying that unix is predefined macro equal to 1. I want to know list of all suc...

-D option is expanded incorrectly from g++ command line

In C++ CodeBlocks project I added the following definitions to the project settings, compiler settings, #define: _DEBUG DATA_DIR=\"/media/Shared/SiX/Data\" This produces the following g++ command line: g++ -Wall -g -fPIC -save-temps -D_DEBUG -DDATA_DIR=\"/media/Shared/SiX/Data\" -I../Includes -c /media/Shared/SiX/SiXConfigurat...

How do you escape a semicolon in COMPILE_FLAGS property of cmake ?

I need to get this as a result in the preprocessor definitions of the msvc generator: MYPATH=\"d:\\;.\\Lib\" But when I use the following escape sequence in set_source_files_properties: set_source_files_properties(source.c PROPERTIES COMPILE_FLAGS "-DMYPATH=\\\"d:\\\;.\\\\Lib\\\"") the generated result is: MYPATH=\"d:\";".\Lib\" ...

xcode seems to ignore preprocesser flags

I've seen all the posts about setting preprocessor flags via the "Preprocessor Macros" setting. For some reason, Xcode seems to ignore my settings. I'm building an Xcode project that was created via CMake. Inside the Dependencies.cmake file, there are a few definitions added. For example: add_definitions(-DUSE_POCO) add_definitions...

Precedence of -D MACRO and #define MACRO

If I have a C file foo.c and while I have given -DMACRO=1 as command line option for compilation. However, if within the header file also I have #define MACRO 2 Which of these will get precedence? ...

#define vs. enums for addressing peripherals

I have to program peripheral registers in an ARM9-based microcontroller. For instance, for the USART, I store the relevant memory addresses in an enum: enum USART { US_BASE = (int) 0xFFFC4000, US_BRGR = US_BASE + 0x16, //... }; Then, I use pointers in a function to initialize the registers: void init_usart (void) { v...

Boost preprocessor: Sample not working

Hi all, I tried to compile a sample from the Boost.Preprocessor library which is: #include <boost/preprocessor/seq/insert.hpp> #define SEQ (a)(b)(d) BOOST_PP_SEQ_INSERT(SEQ, 2, c) // expands to (a)(b)(c)(d) on Visual Studio 2008 and I get the error error C2065: 'b' : undeclared identifier Is there a problem with the sample or am I m...