preprocessor

Why the output for "a" is -80?

#include<stdio.h> #include<conio.h> #define ABC 20 #define XYZ 10 #define XXX ABC - XYZ void main() { int a; a = XXX * 10; printf("\n %d \n", a); getch(); } I thought the output should be 100 but when i saw the result i found o/p as -80. when i put bracket as #define XXX (ABC-XYZ) then i get output as 100 but wi...

C++ conditional compilation

I have the following code snippet #ifdef DO_LOG #define log(p) record(p) #else #define log(p) #endif void record(char *data){ ..... ..... } Now if I call log("hello world") in my code and DO_LOG isn't defined, will the line be compiled, in other words will it eat up the memory for the string "hello world"? P.S...

Help writing a complex macro

Hi all, I am working with a unit-testing suite that hijacks function calls and tests expected output values. The normal layout requires one block of unit-testing code for each expected value. Since my code makes use of a large number of enums, I would like to automate the automated-testing with some for loop / macro magic, and I'm look...

What's the macro to distinguish ifort from other fortran compilers?

I'm working with Fortran code that has to work with various Fortran compilers (and is interacting with both C++ and Java code). Currently, we have it working with gfortran and g95, but I'm researching what it would take to get it working with ifort, and the first problem I'm having is figuring out how to determine in the source code whet...

Is it possible to do a #define in Adobe Flex?

I'm looking for a way to do something similar to a c/c++ #define in adobe flex. I'd like to have lots of different paths a project build can take depending on wither or not something was defined. Does such a thing exist in flex? I know there is ways to set global variables but that wont really suit my purpose. being able to have struct...

Java Preprocessor in C#

Say I want to create a sort of Pre-processor for existing java code, so I can get the language specific keywords and objects, and then create routines that convert them to their Csharp equivalents, using Csharp code - what route should this take? I'm thinking of Regular Expressions, but I'm fuzzed. I have a bunch of about a 100 .java fi...

What does ESP mean in assembly?

ESP = ? stack pointer What does E stand for here? UPDATE RSP for 64bit? What does R mean here? ...

What does the .. in #include "../somefile.h" mean

Does it mean search the previous folder for somefile.h or the project folder for somefile.h? ...

CPP extension and multiline literals in Haskell

Is it possible to use CPP extension on Haskell code which contains multiline string literals? Are there other conditional compilation techniques for Haskell? For example, let's take this code: -- If the next line is uncommented, the program does not compile. -- {-# LANGUAGE CPP #-} msg = "Hello\ \ Wor\ \ld!" main = putStrLn msg ...

preprocessing directives to prevent a project from release and debug symbols

Is there anyway to restrict by using pre-processing directives to prevent a project from compiling when both the Release and Debug symbols are defined? Please let me know. ...

Disable #pragma message("")

Hi, I needed to include in my project but there is a line, in glut.h which is #pragma message("Note: including lib: glut32.lib\n") It is really annoying and I want to get rid of it when compiling. I could just remove the line in my glut.h but I want my fix to be independent of the glut.h. I have tried setting #pragma warnings to sho...

Determining whether compiling on Windows or other system

Hi, Im currently developing a cross-platform C application. Is there any compiler macro which is defined only during compilation on Windows, so I can #ifdef some Windows specific #includes? Typical example is selecting between WinSock and Berkeley sockets headers: #ifdef _WINDOWS #include <winsock.h> #else #include <sys/sock...

Checking the sizeof an integer type in the preprocessor

Possible Duplicate: Why cant I use sizeof in a preprocessor condition ? How can I check the size of an unsigned in the preprocessor under g++? sizeof is out of the question since it is not defined when during preprocessing. ...

Macros in C.... please give the solution

suppose i declared a macro name anything, xyz() and now i am creating another macro xyz1() and referencing the 1st macro i.e xyz() in 2nd. finally i'll create another macro xyz2() and referencing 2nd macro in 3rd... now my question is is this correct(its executing without any problem)..? and macro xyz() is defined twice.... why its no...

gcc run "light" preprocessor

Is there any way to run the gcc preprocessor, but only for user-defined macros? I have a few one-liners and some #ifdef etc... conditionals, and I want to see what my code looks like when just those are expanded. As it is, the includes get expanded, my fprintf(stderr)s turn into fprintf(((__getreeent())->_stderr), etc... ...

How to use Preprocessor directives in MVC aspx pages

I am using MinifyJS.tt which is a T4 template to minify all my JS files automatically. In my aspx files, I am referencing all the javascript files. Now, I want to add a condition (maybe compiler directive) to use the original JS file when I am debugging the application, and to use the minified JS files when I simply run the application ...

CruiseControl.NET Preprocessor 'include' Anomaly

Here's a strange one relating to a combination of the 'define' and 'include' functionality that the CC.NET preprocessor exposes. We're running CCNet 1.4.4.83, and our ccnet.config file is structured and split to make best use of common element blocks stored in subfiles that are included by the main config file; we also split out the core...

C/GCC - Is it possible to sort arrays using preprocessor? [SOLVED]

I have a number of very long arrays. No run-time sort is possible. It is also time consuming to sort them manually. Moreover, new elements can be added in any order later, so I would like to sort them by value using C preprocessor or maybe there is any compilers flag (GCC)? For example: sometype S[] = { {somevals, "BOB", someotherva...

Can we write a portable include guard that doesn’t use the preprocessor in c++ ??

Hi Can we write a portable include guard that doesn’t use the preprocessor in c++ ?? If so how could that be done ? ...

Stringification of a macro value

I faced a problem - I need to use a macro value both as string and as integer. #define RECORDS_PER_PAGE 10 /*... */ #define REQUEST_RECORDS \ "SELECT Fields FROM Table WHERE Conditions" \ " OFFSET %d * " #RECORDS_PER_PAGE \ " LIMIT " #RECORDS_PER_PAGE ";" char result_buffer[RECORDS_PER_PAGE][MAX_RECORD_LEN]; /...