define

See what the preprocessor is doing

Is there anyway to see what you code looks like after the preprocessor has done all the substitutions? ...

C macro processing

Hy. I'm thinking about best way to write C define processor that would be able to handle macros.Unfortunately nothing intelligent comes to my mind. It should behave exactly like one in C, so it handles expressions like this: #define max(a, b) (a > b ? a : b) printf("%d\n", max(a, b)); Or this: #define F 10 #define max(a, b) (a > b ...

Library redefines NULL

I'm working with a library that redefines NULL. It causes some problems with other parts of my program. I'm not sure what I can do about it. Any idea? My program's in C++, the library's in C. #ifdef NULL #undef NULL #endif /** * NULL define. */ #define NULL ((void *) 0) Oh, and it produces these errors: Generic.h:67: error: def...

[C] How to conditionally determine which functions are called at compile time?

I'm working on implementing a very, very basic component system in C, but now I am at a point where I want to 'dynamically' call some functions. The set-up is very easy: the main program is simply an endless while loop, in which some conditions are checked and in which a "process" function is called for each enabled component. For examp...

Defining PHP variables - PHP 101

I'm defining the following variables: $rel_path = bloginfo('template_directory'); $thumb_directory = "$rel_path/images/portfolio/"; $orig_directory = "$rel_path/images/portfolio/thumbs"; the $rel_path is a WordPress function which appears to be printing, however, it is displaying spitting an error message which indicates that $rel_pat...

#define in Java

Hi, I'm beginning to program in Java and I'm wondering if the equivalent to the C++ #define exists. A quick search of google says that it doesn't, but could anyone tell me if something similar exists in Java? I'm trying to make my code more readable. Instead of myArray[0] I want to be able to write myArray[PROTEINS] for example...

Is there any way to have eclipse recognise virtual defines per build configuration?

I am working on an inherited Borland C/C++ project and a lot of the project's functionality is hidden away behind #ifdefs which rely on defines passed to the compiler. I have been trying to get eclipse to activate these sections by using per-configuration symbols however when i view the source files, large sections are still greyed out. ...

Equivalent of #define in Java?

I'm writing a library that needs to have some code if a particular library is included. Since this code is scattered all around the project, it would be nice if users didn't have to comment/uncomment everything themselves. In C, this would be easy enough with a #define in a header, and then code blocks surrounded with #ifdefs. Of cours...

how to undefine a define at commandline using gcc

How do I at compiletime undefine a compiler macro using gcc. I tried some compile args to gcc like -D but I cant get to see the "not defined" message. Thanks #include <iostream> #define MYDEF int main(){ #ifdef MYDEF std::cout<<"defined\n"; #else std::cout<<"not defined\n"; #endif } ...

python equivalent of '#define func() ' or how to comment out a function call in python

my python code is interlaced with lots of function calls used for (debugging|profiling|tracing etc.) for example: import logging logging.root.setLevel(logging.DEBUG) logging.debug('hello') j = 0 for i in range(10): j += i logging.debug('i %d j %d' % (i,j)) print(j) logging.debug('bye') i want to #define these resource consumi...

MSBuild.exe not accepting either /p:DefineConstants nor /p:PreprocessorDefinitions

I've been through quite a number of articles on stack overflow that answered the question "How do I pass preprocessor definitions to the compiler from the MSBuild command line," and they all responded with some variation of: MSBuild.exe /p:DefineConstants=THING_TO_BE_DEFINED I have tried every variation that I could come up with: MSB...

VC++ replaces defines of different objects, GCC etc. not

Hi, I have a big app using many static libs, which is platform independant and deployed under Windows and Linux. All static libs and the main() itself are compiled with two defines: -DVERSION=1.0.0 -DBUILD_DATE=00.00.0000 These defines are used by macros inside each static lib and inside the main to store the current lib version ins...

Defining erlang functions in the shell

Is there any way to define an Erlang function from within the Erlang shell instead of from an erl file? ...

What is sandboxing?

I have read the Wikipedia article, but I am not really sure what it means, and how similar it is to version control. It would be helpful if somebody could explain in very simple terms what sandboxing is. ...

Macro for concatenating two strings in C

Hey, I'm trying to define a macro which is suppose to take 2 string values and return them concatenated with a one space between them. It seems I can use any character I want besides space. for example: #define conc(str1,str2) #str1 ## #str2 #define space_conc(str1,str2) conc(str1,-) ## #str2 space_conc(idan,oop); space_conc woul...

What is the correct way to document PHP constants (define) with phpDocumentor

How must we document (with phpDocumentor) constants defined with define() in PHP? I found nothing in the docs, but found the following example (which I don't see it's use) in the sample2.php: /**#@+ * Constants */ /** * first constant */ define('testing', 6); /** * second constant */ define('anotherconstant', strlen('hello')); ...

How to correctly define char array

Hi all, Does anyone know how should ASF_OBJECT_GUID_TEST be defined to avoid compilation error in the line marked below, or where I can find more information about it? Thanks, Andre #define ASF_OBJECT_GUID_TEST {(char)0x75, (char)0xB2, (char)0x00} void testFunction(char * testChar) { } int main(int argc, char * argv[]) { char t...

Un-define constants with define/apc_define_constants in PHP

I'm using constants for output messages in different languages. For example, if a user chooses "English", a file with this constant would be required: define('welcomeMessage','Welcome!'); If she chooses "Spanish": define('welcomeMessage','Bien Venidos!'); etc etc... The problem occurs when a user iterates through languages. I can...

GCC dump preprocessor defines

Is there a way for gcc/g++ to dump its preprocessor defines from the command line? I mean things like __GNUC__, __STDC__, and so on. ...

Delphi 2009 - Detect if component installed

Hi there, I got some code that I share with another developer. I have a nice debugging module which I leave through out the unit tests but he doesn't have this, so it's a battle of adding and remove the code constantly. Would be nice if there was a way we could use a condition (much like Delphi version or Unicode) like {$IfDef MYCom...