preprocessor

Can I see shader preprocessor output?

I am using #defines, which I pass runtime to my shader sources based on program state, to optimize my huge shaders to be less complex. I would like to write the optimized shader to a file so that next time I run my program, I do not have to pass the #defines again, but I can straight compile the optimized shaders during program startup b...

C++ Code Generation

In my epic quest of making C++ do things it shouldn't, I am trying to put together a compile time generated class. Based on a preprocessor definition, such as (rough concept) CLASS_BEGIN(Name) RECORD(xyz) RECORD(abc) RECORD_GROUP(GroupName) RECORD_GROUP_RECORD(foo) RECORD_GROUP_RECORD(bar) END...

what is a "private header" in c

Hi I've been learning c recently, and in one of my textbooks I found a reference to a file with the extension .r (dot r). Now, as you can imagine, googling "r" or "file extension r" is not productive, so I wonder if you could help me out! It appears in the following code block #include "new.r" static const struct Class _String = { ...

Error building pch file with CPP definitions

We're adding CoreData support to our iPhone app. It's a far reaching change (moving from SQLitePersistentObject). To avoid branching, we are running a single codeline with the new code within #ifdef blocks. When I enable this code from one of my headers (#define CORE_DATA_BUILD) everything works fine. When I create a new target and defi...

C Preprocessor directives and boolean operators

Hello all, I searched the site but did not find the answer I was looking for so here is a really quick question. I am trying to do something like that : #ifdef _WIN32 || _WIN64 #include <conio.h> #endif How can I do such a thing? I know that _WIN32 is defined for both 32 and 64 bit windows so I would be okay with just it for win...

How to Enforce Exactly One Definition?

Given a C project that needs to support multiple environments, how do I use the preprocessor to enforce that exactly one environment is defined? I can already do #if defined PROJA (blah blah blah) #elif defined PROJB (etc) #else #error "No project defined" #endif All that does, though, is tell me if 0 pro...

Visual C++: How to embed and display a compile time message in code?

Is there a way to embed a message in code that is displayed during compile-time when that piece of code is being compiled? The messages are diagnostic in nature and should not modify or abort the compile process. (Disclaimer: I know the answer to this question. I didn't find it asked on Stack Overflow and I think it would be an useful a...

How do I conditionally enable attributes in C#? "#if DEBUG" isn't working!

The trusty old preprocessor directive in C# appear to work great when I write: #if DEBUG ... (Some code) ... #endif However, attributes enclosed in the conditional block appear to continue to get processed and I get errors indicating such. For instance, surrounding an [AssemblyVersion(...)] within the conditional block appears to have...

Seeing expanded C macros

If I want to expand a C macro, what are some good ways to do that (besides tracing it manually)? For instance, GTK_WIDGET_SET_FLAGS, it uses a macro that uses a macro that uses a macro (or two) ... I want to just see it somehow expanded automagically, instead of searching for every macro, every step of the way. UPDATE I tried cpp, bu...

Does a C# preprocessing tool exist?

Hi, Does anyone know of a utility to preprocess a C# source file without compiling it, in a similar fashion to using the -E flag in GCC? I tried using GCC - it successfully processes #if directives, but it chokes on any #region directives... Ideally, I'd like to be able to run the tool over a .cs file to remove any #if blocks that eva...

cl.exe Difference in object files when /E output is the same and flags are the same

Hello: I am using Visual Studio 2005's cl.exe compiler. I call it with a bunch of /I /D and some compilation/optimization flags (example: /Ehsc). I have two compilation scripts, and both differ only in the /I flags (include directories are different). All other flags are the same. These scripts produce different object files (and not j...

compile different code on whether a function is available or not

Windows provides only GetTickCount up to Windows Vista and starting from that OS also GetTickCount64. How can I make a C program compile with calls to different functions? How can I make a C compiler check whether a function is declared in the included header files and compile different portions of code depending on whether that particu...

Generating preprocessed files using bcc32

Does anyone know what the command line option is to generated a preprocessed file using bcc32.exe (version 5.6.4)? I know that using gcc you can use -E to generate .i files. ...

wrapping #includes in #ifndef's - adds any value?

I have inherited C/C++ code base, and in a number of .cpp files the #include directives are wrapped in #ifndef's with the headers internal single include #define. for example #ifndef _INC_WINDOWS #include <windows.h> #endif and windows.h looks like #ifndef _INC_WINDOWS #define _INC_WINDOWS ...header file stuff.... #endif // _INC_WIN...

How do I check the TARGET_NAME of my iPhone app on XCode?

Hi, I'm trying to have 2 version of my iPhone application within the same XCode project. The codebase it's almost the same and where I need to have different behaviours I've decided to use preprocessor's conditionals and the ${TARGET_NAME} tag. I've set the OTHER_CFLAGS to contain "-DTARGET_NAME=${TARGET_NAME}". Then in my code I trie...

"#if DEBUG" in an ASPX/ASCX page

I want to be able to point to one of 2 assemblies based on what mode (DEBUG or RELEASE) I have selected in my VS2005 IDE. Something like this (which does not work): <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VideoDialog.ascx.cs" Inherits="Company.Web.Base.Controls.VideoDialog" %> <% #if DEBUG %> <%@ Register TagPrefi...

How to know which headers are included without looking at the preprocessed code in GCC?

Hi, I've got some big C programs, and I would like to know when I'm compiling this program, which header files are actually included... The simplest solution would be to print the preprocessed code and look but do you know if there's a way to compile and at the same time showing what header files are included ? ...

What is #nomacros (EP003), and is it alive?

The Evolution WG Issues List of 14 February 2004 has ... EP003. #nomacros. See EI001. Note by Stroustrup to be written. In rough (or exact) terms, what is #nomacros, and is it available as an extension anywhere? It would have been a useful diagnostic tool in a recent project involving porting thousands of files of 1995-vintage C...

How does WINVER or WIN32_WINNT affect operating system version as shown by dumpbin

We have an existing (old) codeline that we have recently converted from VC6 to VS2008 (converting to VS2005 along the way). After our conversion, all (or most) of our vcproj files set WINVER to 0x0500 via the Preprocessor Settings. In quite a few of our precompiled headers (typically stdafx.h), WINVER is set to 0x0500 (some still set i...

Discover the class of a methodinvocation in the Annotation Processor for java

I am writing some tools for our build system to enforce some strict calling conventions on methods belonging to classes containing certain annotations. I'm using the Compiler Tree API... What i'm wondering is when traversing the 'tree', how can you tell the type of class/interface for a MethodInvocation. I'm subclassing TreePathScan...