define

Why is this C or C++ macro not expanded by the preprocessor?

Can someone points me the problem in the code when compiled with gcc 4.1.0. #define X 10 int main() { double a = 1e-X; return 0; } I am getting error:Exponent has no digits. When i replace X with 10, it works fine. Also i checked with g++ -E command to see the file with preprocessors applied, it has not replaced X with 10. I was ...

Need help for this syntax: "#define LEDs (char *) 0x0003010"

I'm doing programming of a softcore processor, Nios II from Altera, below is the code in one of the tutorial, I manage to get the code working by testing it on the hardware (DE2 board), however, I could not understand the code. #define Switches (volatile char *) 0x0003000 #define LEDs (char *) 0x0003010 void main() { while (1) *LEDs = *...

C++: use a #define in printf?

I was wanting to use a constant of some kind for the application ID (so I can use it in printf). I had this: #define _APPID_ "Hello World!" And then the simple printf, calling it into %s (string). It put this out: simple.cpp:32: error: cannot convert ‘_IO_FILE*’ to ‘const char*’ for argument ‘1’ to ‘int printf(const char*, ...)’ Wh...

Any utility to test expand C/C++ #define macros?

It seems I often spend way too much time trying to get a #define macro to do exactly what i want. I'll post my current dilemma below and any help is appreciated. But really the bigger question is whether there is any utility someone could recommend, to quickly display what a macro is actually doing? It seems like even the slow trial and ...

PHP How to access constant defined outside class?

I have defined some constants eg: define('DB_HOSTNAME', 'localhost', true); define('DB_USERNAME', 'root', true); define('DB_PASSWORD', 'root', true); define('DB_DATABASE', 'authtest', true); now when I try to do this: class Auth{ function AuthClass() { $this->db_link = mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD) or die(mys...

No instance of constructor --- Matches Argument List (Templating issue maybe)

Hey S.O. Guys I am currently trying to write a basic wrapper for the cml (http://www.cmldev.net/) math library for a project i am working on. I have a wrapper for the cml vector class which has one private member #ifndef VECTOR3_H_ #define VECTOR3_H_ #include "cml\cml.h" #include <memory> namespace Math { template<typename T> ...

Help with defines

Hello, I have some big code line which I want to pack into define for fast using. EventManager::get_mutable_instance().get<EventManager::KeyEvent>("KeyPressed").Call(EventManager::KeyEvent::ArgsType(localEvent.Key)); Here is EventManager is singleton class. I'd prefer to pass into define only EventManager::KeyEvent type and signal nam...

(Embedded) C: void function() or #define FUNCTION()

Hi, im programming embedded devices and I was wondering what to use for a macrofunction, for example an init of some registers. should i make this static/const or define it as a macro? for example, this: #define FPGA_INIT()\ { \ /* Set function and direction of start_code pin*/\ P0SEL &= ~0x04; \ P0DIR |= 0x04; \ FPGA_START_CO...

How do I identify redefined macros in C?

I have two large framework libraries, whose header files are included in my project. Either one works flawlessly, but including both causes erratic behaviour (but no error message related to the macro). I assume that they both #define a macro of the same name. What is the most efficient way to identify the problematic macro? ...

What is the meaning of the '?', '()', and ':' symbols in PHP?

I've finally remembered what to ask. I never really got what : and ? do when a variable is being defined like this: $ip = ($_SERVER['HTTP_X_FORWARD_FOR']) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $_SERVER['REMOTE_ADDR']; As you can see there is ? and : and ( ) Could anyone give me a brief detail about why and how they are used for? Thanks...

How to use abbreviations in Vim with arguments?

In Vim, you can make it so each time you write "FF" on insert mode changes to some code by using: :iab FF for ( int i = 0 ; i < n ; i++ ) But is there any way to use this with arguments? Something like C's #defines, so if I write FF(e, 10) It becomes for ( int e = 0 ; e < 10 ; e++ ) ...

How can I get the compiler tell me what file #define a value?

My code is linking against several other libraries that are also developed at my company, one of these libraries is redefining several values from errno.h, I would like to be able to fix this, however I am having trouble finding the exact file that is redefining these values, I am want to know if there is a way to make the compiler tell ...

Preprocessor macro based code yields a C2400 error

#define CANCEL_COMMON_DIALOG_HOOK(name) \ void __declspec(naked) ##name##CancelCommonDialogHook(void) \ { \ __asm \ { \ add esp, [k##name##CancelCommonDialogStackOffset] \ jz RESTORE \ jmp [k##name##CancelCommonDialogNewFileRetnAddr] \ RESTORE: \ pushad \ call ...

Defining a byte in C++

In http://www.parashift.com/c++-faq-lite/intrinsic-types.html#faq-26.6, it is wriiten that "Another valid approach would be to define a "byte" as 9 bits, and simulate a char* by two words of memory: the first could point to the 36-bit word, the second could be a bit-offset within that word. In that case, the C++ compiler would need to ad...

Define's in Action script

I'm trying to pass a build number from Hudson into a Flex application. I've found Adobe's document (http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html) on conditional compilation which seems it should solve it but i must be missing something. So in my ant build file i have:- <mxmlc file="${app.dir}/${app...

#defines in objective-c

How do #defines work in objective-c? I have a background in C/C++ and am now trying to pick up objecive-c. #defines don't seem to work in objective-c the same way they work in c and c++, where the compiler just replaces all references to the defines with what they are supposed to represent. When I try to use #defines in objective-c they...

Size of #define values

If a value is defined as #define M_40 40 Is the size the same as a short (2 bytes) or is it as a char (1 byte) or int (4 bytes)? Is the size dependent on whether you are 32-bit or 64-bit? ...

Meaning of #undef in C++

i know what this means #define M(B) (1U << ((sizeof(x) * CHAR_BIT) - B)) // CHAR_BIT=bits/byte but i dont understand well this one #undef M after this what happens? M is cleared or deleted or? ...

Define not evaluating POD?

I was going over the C++ FAQ Lite online. I was browsing inlines again since I haven't found a use for them and wanted to know how the stopped the circular dependency as showed in this answer. I first tried to do the, "Why inlines are better than defines." example with the following code: #define unsafe(i) \ ( (i) >= 0 ? (i) : -(i) ...

xor definition (this sentence is to make the title acceptable)

Possible Duplicate: What does ^ do in c# (Enums)? This may be a noobish question but...nowhere have I seen what Xor means in c++ or c#. I think it might mean and/or and if it does, im smart cause that's a blind guess =D. I use c# now but im pretty sure xor means the same thing. The problem is - I don't know what xor means. ...