Re: Using #define a good way for String constants, like enums for NSIntegers?

2011-08-10 Thread Daniel DeCovnick
The disadvantage is if you need to use string constants across binaries (such as constants used by plugins). If you strip symbols, you can't use them at all (whereas you can use #defines from an imported header file). If you don't strip symbols, you still need to declare them as follows:

Re: Using #define a good way for String constants, like enums for NSIntegers?

2011-08-10 Thread Chris Hanson
If you're exporting symbols, you could have the visibility attribute be part of the macro you wrap around 'extern' anyway: #if defined(__cplusplus) #define MY_EXTERN extern C #else #define MY_EXTERN extern #endif #define MY_EXPORT MY_EXTERN __attribute__((visibility(default))) (The

Using #define a good way for String constants, like enums for NSIntegers?

2011-08-09 Thread Devraj Mukherjee
Hi all, I am writing an API client for a REST service, parts of the REST API returns fixed String values. E.g. status of an order. I want to represents these fixed responses as constants. I have represented fixed numeric values using enums and used a typedef to represent the data type. Are

Re: Using #define a good way for String constants, like enums for NSIntegers?

2011-08-09 Thread Vyacheslav Karamov
Don't forget about @: #define MY_FUNNY_STR @Ha-ha-ha! 09-Aug-11 13:47, Devraj Mukherjee пишет: Hi all, I am writing an API client for a REST service, parts of the REST API returns fixed String values. E.g. status of an order. I want to represents these fixed responses as constants. I have

Re: Using #define a good way for String constants, like enums for NSIntegers?

2011-08-09 Thread Jerry Krinock
On 2011 Aug 09, at 03:47, Devraj Mukherjee wrote: Are Strings defined using #define good enough as String constants? It will work, but is considered to be bad form, I think because it could bloat your code some trivial amount by having a constant defined multiple times, if the compiler does

Re: Using #define a good way for String constants, like enums for NSIntegers?

2011-08-09 Thread Ken Thomases
On Aug 9, 2011, at 7:58 AM, Jerry Krinock wrote: This is how it's usually done: In a .m, .c or .cpp file, NSString* const constEntityNameLog = @Log_entity ; and if you need to use this constant in other files, add, in the counterpart header file, extern NSString* const

Re: Using #define a good way for String constants, like enums for NSIntegers?

2011-08-09 Thread Gregory Weston
Devraj Mukherjee wrote: I am writing an API client for a REST service, parts of the REST API returns fixed String values. E.g. status of an order. I want to represents these fixed responses as constants. I have represented fixed numeric values using enums and used a typedef to represent

Re: Using #define a good way for String constants, like enums for NSIntegers?

2011-08-09 Thread Chris Hanson
On Aug 9, 2011, at 3:47 AM, Devraj Mukherjee wrote: I am writing an API client for a REST service, parts of the REST API returns fixed String values. E.g. status of an order. I want to represents these fixed responses as constants. I have represented fixed numeric values using enums and

Re: Using #define a good way for String constants, like enums for NSIntegers?

2011-08-09 Thread Chris Hanson
On Aug 9, 2011, at 10:10 AM, Gregory Weston wrote: I'm still generally in favor of named constants over pre-processor substitution. Gives you types and no worry about parentheses. You can also use the global constant in the debugger (including in command completion) because it has a symbol