preprocessor

Preprocess strings file during Xcode build

Hello, I know there's a way to preprocess my info.plist file, but is there a similar way to process strings files inside my Settings.bundle? My problem: I have an iPhone app and I want the the user to know about the currently installed version. I do this by displaying it in the apps settings. Now every time i change the bundle version ...

C++ Preprocessor string literal concatenation

I found this regarding how the C preprocessor should handle string literal concatenation (phase 6). However, I can not find anything regarding how this is handled in C++ (does C++ use the C preprocessor?). The reason I ask is that I have the following: const char * Foo::encoding = "\0" "1234567890\0abcdefg"; where encoding is a stati...

Linker, Libraries & Directories Information

I've finished both my C++ 1/2 classes and we did not cover anything on Linking to libraries or adding additional libraries to C++ code. I've been having a hay-day trying to figure this out; I've been unable to find basic information linking to objects. Initially I thought the problem was the IDE (Netbeans; and Code::Blocks). However I'...

[MSVC++ 2008] Using preprocessor directives to define command line options

If I wanted to add, let's say, a new .lib to the build only if a particular #define was set, how would I do that? In the MSVC++ 2008 "Property Pages", you would simply add: Config Properties -> Linker -> Input -> Additional Dependencies, but I would like it if something like #define COMPILE_WITH_DETOURS was set, then the particular libr...

[MSVC++ 2008] Using preprocessor directives to define the output path

Using the following pseudo-code: #define BUILD_PATH "C:/MyBuild/" #define BUILD_NAME "mydll.dll" // Set build path here representing how I would like to build the current project (a dll) into C:/MyBuild/mydll.dll, how would I accomplish this by only using preprocessor directives? Thanks a bunch! ...

C/C++ line number

In the sake of debugging purposes, can I get the line number in C/C++ compilers? (standard way or specific ways for certain compilers) e.g if(!Logical) printf("Not logical value at line number %d \n",LineNumber); // How to get LineNumber without writing it by my hand?(dynamic compilation) Thanks ...

What exactly does an #if 0 ..... #endif block do?

In C/C++ What happens to code placed between an #if 0/#endif block? #if 0 //Code goes here #endif Does the code simply get skipped and therefore does not get executed? ...

What is the usage of #if DEBUG pre-processor directive in c#? When must we use this?

What is the usage of #if DEBUG pre-processor directive in c#? When must we use this? ...

Using the Antenna and J2ME Polish preprocessors interchangeably and setting a variable value

I have J2ME code, which I want to be able to compile using the J2ME Polish preprocessor or the wtkpreprocessor (antenna). They mostly use the same directives so it usually works, but ... When I want to insert an URL value in the Java code this gives a problem. In Antenna the code would look like this: //#ifdef my.url //# System.ou...

Which of the C-family languages have a preprocessor?

Among the C-syntax family of languages (C, C++, Java, C#, ObjC, JS, AS, ...), which have a preprocessor compatible (to whatever extent) with the C preprocessor? ...

Use a template parameter in a preprocessor directive?

Is it possible to use a non-type constant template parameter in a preprocessor directive? Here's what I have in mind: template <int DING> struct Foo { enum { DOO = DING }; }; template <typename T> struct Blah { void DoIt() { #if (T::DOO & 0x010) // some code here #endif } }; When I try this ...

C Preprocessor: #define in C... advice

Hi Guys, I'm making a big C project and I have never come across a situation like this before so, I need your advice. What is your opinion? Is it okay to have the constants defined within conditional preprocessors like I have done below or you advise me to do this some other way? #define NUM_OCTAVES_4 //#define NUM_OCTAVES_5 #ifde...

Macros's that define macros

Possible Duplicate: C, Macro defining Macro Does anyone know how to pull off something like this... I have alot of repetitive macros as : - #define MYMACRO1(x) Do1(x) #define MYMACRO2(x,y) Do2(x, y) #define MYNEXTMACRO1(x) Do1(x) #define MYNEXTMACRO2(x,y) Do2(x, y) The code above works fine, but I want ...

Can I use #undef this way?

I want to get some settings I store in the registry, and if they differ from a #define I want to redefine it, could I do it this way?: #define DEFINED_X "testSetting" void LoadConfig() { regConfigX = some value previusly stored in the registry; if(regConfigX!=DEFINED_X) { #undef DEFINED_X #define DEFINED_X r...

Looking for a good explanation of the table generation macro idiom

I want to make this clear up front : I know how this trick works, what I want is a link to a clear explanation to share with others. One of the answers to a C macro question talks about the "X macro" or "not yet defined macro" idiom. This involves defining something like: #define MAGIC_LIST \ X(name_1, default_1) \ X(name_2, de...

C language preprocessor behavior

There are different kind of macros in C language, nested macro is one of them. Considering a program with the following macro #define HYPE(x,y) (SQUR(x)+SQUR(y)) #define SQUR(x) (x*x) Using this we can successfully compile to get the result. As we all know the C preprocessor replaces all the occurrence of the identifiers with the...

Are preprocessors obsolete in modern languages?

Hello, I'm making a simple compiler for a simple pet language I'm creating and coming from a C background(though I'm writing it in Ruby) I wondered if a preprocessor is necessary. What do you think? Is a "dumb" preprocessor still necessary in modern languages? Would C#'s conditional compilation capabilities be considered a "preprocessor...

Visual C++ 2010 solution-wide macros with parameters

I'm trying to compile some source code with Visual C++ 2010 Express. The code was written for GCC, and contains attributes like this: struct something { ... } __attribute__((packed)); Since this is not standard C++ syntax, Visual C++ doesn't recognize it. With this macro prior to the struct declaration, it works fine: #define __attri...

using #define one time for multiple source files

is there a way in visual c++ to #define something in a cpp file and have it defined in other cpp files as well? ...

Remove extra junk from C preprocessor?

I'm trying to use the C preprocessor on non-C code, and it works fine except for creating lines like this at the top: # 1 "test.java" # 1 "<built-in>" # 1 "<command-line>" # 1 "test.java" The problem is that these lines aren't valid in Java. Is there any way to get the preprocessor to not write this stuff? I'd prefer not to have to ru...