preprocessor

Embedded SQL in OO languages like Java

One of the things that annoys me working with SQL in OO languages is having to define SQL statements in strings. When I used to work on IBM mainframes, the languages used an SQL preprocessor to parse SQL statements out of the native code, so the statements could be written in cleartext SQL without the obfuscation of strings, for instanc...

In C and C++, why is each .h file usually surrounded with #ifndef #define #endif directives?

Why does each .h file starts with #ifndef #define #endif? We can certainly compile the program without those directives. ...

Newbie C #include Question

I roughly understand the rules with what #include does with the C preprocessor, but I don't understand it completely. Right now, I have two header files, Move.h and Board.h that both typedef their respective type (Move and Board). In both header files, I need to reference the type defined in the other header file. Right now I have #incl...

iphone project constant

Hello, I want to have a constant in my project to change between Lite and Pro version. I don't think it is the best way to do it, but I am trying to: add a constant in my app delegate #define BUILD_PRO 1 //0 => LITE, 1 => PRO when I need it I import the appDelegate and test it: #import "myAppDelegate.h" then later #if (BUILD_PRO...

Qt's pragma directives

Hi, Could anyone point me out to an article, where pragma directives, available in Qt enviroment would be discussed? Thank you. ...

WiX undefined preprocessor variable

I'm starting to use WiX in order to do automated builds to create msi's of my c# projects and am experiencing the error "Undefined preprocessor variable '$(var.MyProject.TargetDir)'" I am using the latest WiX v3.0.5419. Inside my wxs file I am trying to use pre-processor variables that are listed on this webpage (http://blogs.msdn.com/j...

How to single-quote an argument in a macro?

I would like to create a C pre-processor macro that will single-quote the argument. Just like the common used #X. I want Q(A) to be expanded to 'A'. I am using gcc on Linux. Does any one have an idea? I know # double-quotes. I am looking for a similar mechanism fir single-quoting. ...

Javascript-friendly preprocessor dilemma.

I've been working on a (nearly finished) Javascript project for a little over 14 months now. The project started out as a hack I expected to finish overnight, but over time the Javascript part has grown up to be 68 separate files and 10,314 non-empty lines, sadly currently dependent on the C preprocessor for building. It's hard to expla...

What is the downside of using the preprocessor to define a function call

I would like to know what the cons are of using the preprocessor in such a way: #define SOME_FUNCTION someFunction(someArgument) Basically I feel like this is wrong (or certainly not a best practice) - but I'm not sure why... my preprocessor skills are rusty at best. thanks, A ...

How can I make the preprocessor insert linebreaks into the macro expansion result?

With C/C++ macros it's quite easy to generated long constructs automatically. For example, if I want a huge set of methods to not ever throw exceptions (a must for COM-exposed methods) I can do something like this: #define BEGIN_COM_METHOD\ try{ #define END_COM_METHOD\ return S_OK;\ } catch( exception& ) {\ // set I...

Passing variables to #include through #define

Is it possible to do something along these lines: #define import_and_other(s)\ something\ #include s Such that: import_and_other("file.h") becomes: something #include "file.h" Basically, there are certain files that always need the same action taken before they are included, so I want to wrap up #include to perform these actions...

C++ preprocessor __VA_ARGS__ number of arguments

Simple question for which I could not find answer on the net. In variadic argument macros, how to find the number of arguments? I am okay with boost preprocessor, if it has the solution. If it makes a difference, I am trying to convert variable number of macro arguments to boost preprocessor sequence, list, or array for further reproce...

Preprocess SHPAML in Django's template loader?

Is there any way to make Django's template loader run all templates it loads (i.e. directly or via extend/include) through SHPAML if it figures the HTML is out of date? I know how to invoke SHPAML recursively over an entire directory, but I would prefer to be able to run it on demand so I don't have to remember to sync the HTML every ti...

Enable "Debug mode" in ASP.NET MVC app through the use of C# directives

My actions in ASP.NET MVC controller are decorated with numerous properties like this [OutputCache(Duration = 86400, Location = OutputCacheLocation.Client, VaryByParam = "jsPath;ServerHost")] [CompressFilter] public JavaScriptResult GetPendingJavaScript(string jsPath, string serverHost) What I would like to do is ...

Recommend C front-end that preserves preprocessor directives.

I'd like to start a project that involves transforming C code, but I'd like to include the preprocessor directives. I don't want to reinvent the wheel by writing my own C parser, so does anyone know of a front-end that can parse C preprocessor and C code, and produce an AST that can be used to re-generate (or pretty-print) the original ...

Resolving typedefs in C and C++

I'm trying to automatically resolve typedefs in arbitrary C++ or C projects. Because some of the typedefs are defined in system header files (for example uint32), I'm currently trying to achieve this by running the gcc preprocessor on my code files and then scanning the preprocessed files for typedefs. I should then be able to replace t...

C#: writing MSIL to add a preprocessor directive

Is it possible in C# to write MSIL code that will add a preprocessor directive to the code, e.g., #warning, if a certain condition is met? Or maybe this can be done with reflection, I don't know. I'm trying to write a custom attribute that, if applied incorrectly to a class's method or property, will generate a compiler warning. Using...

Checking the return value of a function in a macro

I have core function which i can call from the customized module of the product. function_core is the core function which will return and integer we have a macro in header file #define func_cust function_core i am calling func_cust inside my customized code. EDIT: but inside the core we again call some other core function #defin...

How to convert concatenated strings to wide-char with the C preprocessor?

I am working on a project where I have many constant strings formed by concatenation (numbers, etc.). For example, I have a LOCATION macro that formats __FILE__ and __LINE__ into a string that I can use to know where I am in the code, when printing messages or errors: #define _STR(x) # x #define STR(x) _STR(x) #define LOCATION _...

C preprocessor in include header files

Hi All. I have a structure defined in a header file called data.h I am including data.h in myfile.c in the structure, I have part of the variables blocked off with #ifndef TEST int x; #endif and in myfile.c i have #ifdef TEST localx++; #else mystruct.x++; //<-compiler complains on this line when compiling #endif When I try to ...