Is it possible to create a preprocessor like functionality that is available in C and provided by Antenna. Can we use the APT tool to achieve this functionality? Are there any articles or links on similar topics?
...
I'm working in an embedded system (RTXC) where I need to disable the debugger functionality which is enabled through a #define command. However, when I change the #define to undefine, compilation goes off fine, but when the linker runs, it encounters an error about a symbol not existing that belongs to the debug code (which should have ...
I want my XCode Objective-C project to be able to detect which configuration it is being built with. How can I achieve this?
Thanks in advance.
...
Is it possible in C++ to stringify template arguments?
I tried this:
#define STRINGIFY(x) #x
template <typename T>
struct Stringify
{
Stringify()
{
cout<<STRINGIFY(T)<<endl;
}
};
int main()
{
Stringify<int> s;
}
But what I get is a 'T', and not an 'int'. Seems that the preprocessors kicks in before tem...
I am trying to write a code, where name of functions are dependent on the value of a certain macro variable. To be specific, I am trying to write a macro like this:
#define VARIABLE 3
#define NAME(fun) fun ## _ ## VARIABLE
int NAME(some_function)(int a);
Unfortunately, the macro NAME() turns that into
int some_function_VARIABLE(int ...
Hello,
I have question regarding macros. How could I cast through macro a template class to normal class. In example:
#define RUNTIME_CLASS(class_name) ((CRuntimeClass*)(&class##class_name))
template<typename T> A {};
if (RUNTIME_CLASS(A));
I know that this code woun't compile because it will not see template bit. But I don't unders...
I know that this will not work, but hopefully you can see what I'm trying to do
#if ASSIGN_ALLOWED
#define MAYBE_SKIP_REST_OF_LINE
#else
#define MAYBE_SKIP_REST_OF_LINE ; //
#endif
char str[80] MAYBE_SKIP_REST_OF_LINE = "Hello\n";
long array[3] MAYBE_SKIP_REST_OF_LINE = { 7,8,9 };
int x MAYBE_SKIP_REST_OF_LINE = 3;
//...
I am looking after a huge old C program and converting it to C++ (which I'm new to). There are a great many complicated preprocessor hacks going on connected to the fact that the program must run on many different platforms in many different configurations. In one file (call it file1.c) I am calling functionA() and in another file (call ...
Consider this (horrible, terrible, no good, very bad) code structure:
#define foo(x) // commented out debugging code
// Misformatted to not obscure the point
if (a)
foo(a);
bar(a);
I've seen two compilers' preprocessors generate different results on this code:
if (a)
bar(a);
// and
if (a)
;
bar(a)
Obviously, this is a bad thing ...
Why doesn't #IF Not DEBUG work the way I'd expect in VB.NET?
#If DEBUG Then
Console.WriteLine("Debug")
#End If
#If Not DEBUG Then
Console.WriteLine("Not Debug")
#End If
#If DEBUG = False Then
Console.WriteLine("Not Debug")
#End If
' Outputs: Debug, Not Debug
But, a manually set const does:
#Const D = True
#If D Then
Con...
Is it possible to make a custom operator so you can do things like this?
if ("Hello, world!" contains "Hello") ...
Note: this is a separate question from "Is it a good idea to..." ;)
...
What, if anything, is the difference between these directives?
#ifdef FOO
#if defined FOO
#if defined(FOO)
I'm using the CCS compiler, but I'm interested in other C compilers as well.
...
I am analyzing a legacy code which heavily using macro , I am lost in understanding how macro are expanding in code.
Could any one suggest me some tool or technique so that i can study actual code generated from macro expansion.
Platform : Windows XP
Language : C++
Compiler : VC6
Thanks in Advance
...
I want to set GCC_PREPROCESSOR_DEFINITIONS for each of my four build configurations (Debug, Release, Ad Hoc, and Distribution.) I'd like to have a different setting for each.
The screen I'm looking at is the Target Info window's "Build" tab. When I set the Configuration pop-up to "Debug" I can see my GCC_PREPROCESSOR_DEFINITIONS settin...
For some reason I need to temporarily disable some macros in a header file and the #undef MACRONAME will make the code compile but it will undef the existing macro.
Is there a way of just disabling it?
I should mention that you do not really know the values of the macros and that I'm looking for a cross compiler solution (should work ...
I saw the following question:
http://stackoverflow.com/questions/98944/how-to-generate-a-newline-in-a-cpp-macro
Let me give a brief requirement of a need in newline in a C++ preprocessor. Am working on ARM Realview compiler 3.1 on a code which uses embedded assembly code with C++ code.
#define DEFINE_FUNCTION(rtype, op, val) \
__as...
C++ allows you to use the #define preprocessor directive to define symbolic constants which the compiler will replace before compilation. My question is, how do compilers typically store these internally and do they have data types?
...
I have a boost pre-processor sequence defined as
#define MY_SEQ ((a) (b1) (b2))\
((b) (b3) (b4) (b1))
I want to generate two enums from this as,
enum alist{a,b}; and enum blist{b1,b2,b3,b4};
The code below does not remove the duplicates from blist (LIST2 macro).
Is it possible to remove the duplicates from the pre-processor list...
Hi, as the questions says, is the C preprocessor able to do it?
E.g.:
#define PI 3.1416
#define OP PI/100
#define OP2 PI%100
Is there any way OP and/or OP2 get calculated in the preprocessing phase?
Thanks.
...
I am trying to figure out what version of Boost my code thinks it's using. I want to do something like this:
#error BOOST_VERSION
but the preprocessor does not expand BOOST_VERSION.
I know I could print it out at run-time from the program, and I know I could look at the output of the preprocessor to find the answer. I feel like having...