define

How to temporarily replace one primitive type with another when compiling to different targets?

How to easily/quickly replace float's for doubles (for example) for compiling to two different targets using these two particular choices of primitive types? Discussion: I have a large amount of c# code under development that I need to compile to alternatively use float, double or decimals depending on the use case of the target assembl...

Why aren't there macros in C#?

When learning C# for the first time, I was astonished that they had no support for macros in the same capacity that exists in C/C++. I realize that the #define keyword exists in C#, but it is greatly lacking compared to what I grew to love in C/C++. Does anyone know why real macros are missing from C#? I apologize if this question is al...

Conflict between a namespace and a define

I have this serious problem. I have an enumeration within 2 namespaces like this : namespace FANLib { namespace ERROR { enum TYPE { /// FSL error codes FSL_PARSER_FILE_IERROR,... and somewhere else in my code, I use it like this : FANLib::Log::internalLog(FSLParser::FILE_IERROR, file_ierror, true, FANLib::ERROR::FSL_PARSER_FIL...

How to tame the Windows headers (useful defines)?

In one of the answers to this question jalf spoke about useful define NOMINMAX, that could prevent from unwanted defining min/max macros. Are there other useful defines that can help to control windows.h (or other Windows headers, for instance Microsoft C Runtime headers or STL implementation) behavior? ...

C++ #define preprocessor

I need to know that does the #define directive in C++ declares global label? By global I mean visible in every file? I'm using Visual Studio 2008, (guess if that matters) ...

#define value in stringFormat ?

I have a define: hashdefine kPingServerToSeeIfInternetIsOn "http://10.0.0.8" then in code I with to use it: NSString *theURL = [NSString stringWithFormat:@"%@", kPingServerToSeeIfInternetIsOn]; I get an exception. What's the best way to define the const for the application and use it in a NSString init? ...

Can i define UIView as a variable in Objective-C?

According to documents i read, they always show that I should define a subview in a class. Like this : @interface PolygonView : UIView. I have to inherit from UIView. Could i define a variable with UIView type in a class which inherit from NSObject? After that, i make a connection from that variable to UIView which is defined in Inter...

Does the C preprocessor strip comments or expand macros first?

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 ...

Highlighting #defined value in VIM

Hi all, I have XYZ highlighted in the header file where I have defined XYZ. However at the point of where it is used, XYZ is not highlighted. How would I fix this ? I have attached two screen shots (see TH_SYN in the code) to clarify my question- link text Any pointers are welcome. Many thanks. ...

Delphi - Scope of custom definitions

Good Morning, I have a unit which I want to use in two different programs, to tell the difference I wanted to Define a symbol and then check that in the unit. In my DPR for the project I have; program Project1; {$Define MYDEF} uses Forms, ... and in my Form1 file I have procedure TForm1.FormCreate(Sender: TObject); begin {...

What C preprocessor conditional should I use for OS X specific code?

What C preprocessor conditional should I use for OS X specific code? I need to include a specific library if I am compiling for OS X or a different header if I am compiling for Linux. I know there is __APPLE__ but I don't know if that is a current conditional for OS X 10.x. ...

C macro : turn a number into a string

I have a table that defines symbols appearance on a 5x7 dot display. Something like: extern UINT8 symbols[][5] = { {0x0,0x0,0x0,0x0,0x0}, {0x0,0x0,0x5F,0x0,0x0}, {0x0,0x7,0x0,0x7,0x0}, {0x14,0x7F,0x14,0x7F,0x14}, // etc. The leading part of the table matches ASCII table, followed by a set of special symbols, e.g. an ...

#define in yacc/bisson lex

How would i implement #define's with yacc/bison? I was thinking all define characters much match a regular varaible. Variables are defined as [a-zA-Z_][a-zA-Z0-9_]* so i figure i can put a check there to see if the variable is a define'd worked or not. Then replace the text with what it should be. How can i do that? Right now i want to...

When to use function-like macros in C

Hi, I was reading some code written in C this evening, and at the top of the file was the function-like macro HASH: #define HASH(fp) (((unsigned long)fp)%NHASH) This left me wondering, why would somebody choose to implement a function this way using a function-like macro instead of implementing it as a regular vanilla C function? Wha...

C - alternative to #ifdef

I'm trying to streamline large chunk of legacy C code in which, even today, before doing the build guy who maintains it takes a source file(s) and manually modifies the following section before the compilation based on the various types of environment. The example follows but here's the question. I'm rusty on my C but I do recall that ...

Select a function at compile time

Hi, in my C project I have five different function (with the same name) which implement one algorithm but in different ways. At compiler time I need to select only one of these functions. Can I implement this using a #define and a bunch of #ifndef? Are there better ways to do this? ...

c define 64bit on 32bit

If I do: #define TIMEFIXCONST 11644473600 on a 32bit machine, will it overflow or will it be stored as a long long and still work properly? Should I just define a global unsigned long long and use that instead? ...

What does this define statement mean?

I have this code to draw an ellipse in the screen but i dont understand what does it means the long define statement, and i only want to know how to write the same code without all that confuse define statement. #define incx() x++, dxt += d2xt, t += dxt #define incy() y--, dyt += d2yt, t += dyt void ellipse(int xc, int yc, int rx, int...

Why are #ifndef and #define used in c++ header files

I have been seeing code like this usually in the start of header files #ifndef HEADERFILE_H #define HEADERFILE_H and at the end of the file is #endif I am confused about the purpose of this ..? ...

How can I keep doxygen from documenting #defines in a C file?

I have #define values in headers that I certainly want Doxygen to document but I have others in C files that I treat as static constants and I don't want Doxygen to document them. Something as simple and stupid as #define NUMBER_OF(a) (sizeof((a))/sizeof((a)[0])) #define MSTR(e) #e How can I keep Doxygen from putting those #defines i...