Being a C novice I would like to hear what Macro "define"s developers are using. I've been thinking about putting these in a header to skip verbosity I've become used to:
#define TS_ typedef struct {
#define _TS(x) } x;
#define I(x)_ { int i; for ( i = 1; i <= x; i++ ) {
#define _I } }
Can I add \n \t etc within these macros? ...
I've come up with a solution to a problem but I'm not sure if it'll always work or just on my compiler. First, the problem: I've noticed in a number of situations it's desirable to have a template class that gets reinstantiated each time it's used even when given the same types (say your template class has static members that are initial...
I'm using Eclipse CDT for a C project with custom makefiles, and I want to use the inactive code highlighting as proposed in the answers to question 739230. The automatic discovery of active/defined symbols does not work for my makefiles. Instead I have created a text file for each build target listing the active symbols.
So my question...
I have a C++ source file and a Python source file. I'd like the C++ source file to be able to use the contents of the Python source file as a big string literal. I could do something like this:
char* python_code = "
#include "script.py"
"
But that won't work because there need to be \'s at the end of each line. I could manually copy a...
I have a situation where I have quite a few generated functions, and would like to point them at some generic functions that I have created (to allow me to reuse the base code when the generated function names change).
Essentially, I have a list of function names as follows:
void Callback_SignalName1(void);
void Callback_SignalName2(vo...
I have an Objective-C/C++ application which uses functionality that is provided by a C++ library.
One of the C++ classes includes an enum like this:
class TheClass
{
public:
[...]
enum TheEnum
{
YES,
NO,
};
[...]
};
Including (using #import -if that matters-) a header file with the above class declaration in an Objective-C/...
Say I have a macro, FOO(name), and some template class Bar<> that takes one parameter (what type of parameter is the question). Everytime I call FOO with a different name, I want to get a different instantiation of Bar. The Bar<> template doesn't actually need to be able to get at the name internally, I just need to be sure that differen...
Hi, I've made a basic interpreter before in C with a preprocessor that took a lot of load off of parsing and such. I would like to port this preprocessor for use in C# now and I'm having trouble, as I am still quite new to C#.
My old preprocessor made it so things like
var $mine= this;
//weird intendtation
var $some...
I am working on a VC++ project under VS2008. My resource files contain some pre-processor directives for conditional compilation. Some of the symbols controlling the conditional compilation are defined in stdafx.h. I need these symbols to be visible to the resource compiler as well. How do I make this happen?
...
Hi,
Initially I thought I needed this, but I eventually avoided it. However, my curiosity (and appetite for knowledge, hum) make me ask:
Can a preprocessor macro, for instance in
#include "MyClass.h"
INSTANTIATE_FOO_TEMPLATE_CLASS(MyClass)
expand to another include, like in
#include "MyClass.h"
#include "FooTemplate.h"
template c...
I have a large application that i can build through the command line. I want to specify a flag that enables me to compile it into either one of two modes, Actual or Simulated.
So the main issue is, how can i use the preprocessor to programmatically add a reference?
For example:
#if SIMULATED
include SimulatedFiles;
myFact...
You can see what i'm trying to do below:
typedef struct image_bounds {
int xmin, ymin, xmax, ymax;
} image_bounds;
#define IMAGE_BOUNDS(X) ((image_bounds *)(X));
typedef struct {
image_bounds bounds;
float dummy;
} demo;
int
main(void) {
demo my_image;
/* this works fine */
((image_bounds *)(&my_image))->xmin...
I've been a Java and VB.Net programmer for about 4 years and a C# programmer for about 6 months. I've also used a bunch of dynamic languages like Perl, Python, PHP, and JavaScript.
I've never had a need for a preprocessor.
My question is: why do you see such extensive use of preprocessors in C, C++, and Objective-C but rarely (or neve...
I'm writing a small deployment SQL script for my first database-driven app.
In the process, I find that I repeat myself a lot, for instance:
GRANT USAGE ON *.* TO 'foo'@'localhost';
DROP USER 'foo'@'localhost';
CREATE USER 'foo'@'localhost' IDENTIFIED BY 'password';
It would be fantastic if I could use a variable or a macro to replac...
Is it possible to define a C/C++ macro "BUILD(a, i)" which expands to "x[0], x[1], x[2], ..., x[i]" ? Like in
#define BUILD(x, 0) x[0]
#define BUILD(x, 1) x[0], x[1]
#define BUILD(x, 2) x[0], x[1], x[2]
...
Thanks!
Edit:
It seems BOOST_PP_ENUM_PARAMS could do the job. I suppose I could just #include boost, but I'm interested in know...
Hi all,
I'm trying to build an app for both J2ME and J2SE. The presentation code will obviously be different, but I'm hoping to keep the logic common, as much as possible.
My plan is to use Ant or Antenna's preprocessor to select either the J2ME or J2SE Graphics object, with that class being the only intersection between my logic and d...
I've recently started getting a little creative with how I handle my js source files. I'm using a build processing for javascript developement, and I really like it.
I've also started playing with a few javascript template engines.
I want to include my templates in my js files. Multi-line strings are, of course, very hard to deal wit...
The documentation tells me that /D command-line switch can be used to do this, like so:
CL /DDEBUG TEST.C
would define a DEBUG symbol, and
CL /DDEBUG=2 TEST.C
would give it the value 2.
But what do I do if I would like to get the equivalent of a string define, such as
#define DEBUG "abc"
?
...
In C++, is this:
#ifdef COND_A && COND_B
the same as:
#if defined(COND_A) && defined(COND_B)
?
I was thinking it wasn't, but I haven't been able to find a difference with my compiler (VS2005).
...
Hi,
I'd like the following to appear in every source file in my Visual C++ 2005 solution:
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
Is there a way of doing this without manually copying it in? Compiler option?
Cheers
...