Re: [Dev-C++] Can I create a string from a non-string #define value??
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <mi...@ne...> - 2005-12-16 15:13:25
|
It is quite alright sending it to my personal email. Infact, if you =
would wish to converse through that means, I have no problems with it.
I assume, now, that you're passing the -D option to the compiler to =
assign defines.
If that is the case, Here is a test program I just wrote to make it =
work.
---code--
#include <stdio.h>
int main ()
{
printf("%s\n\r", RELEASE);
return 0;
}
--code--
And I compiled it this way (used my linux machine and GCC, but dev-cpp =
uses mingw, so you can set the compile options)
gcc def.c -DRELEASE=3D\"2.2\" -o def -ggdb
Notice the use of quotes? Try it.=20
Output:
./def
2.2
Hope this helps,
Mike.
www.nanobit.net
----- Original Message -----=20
From: Minds Work=20
To: dev...@li...=20
Sent: Friday, December 16, 2005 6:28 AM
Subject: Re: [Dev-C++] Can I create a string from a non-string #define =
value??
Hi Mike,
This would work if the #define was in the code.
But my problem is that the the #define came from a command line, and i =
CANT put the "" on it.
(As I said before, I cannot change the value format)
I need something in the code the gets the #define value that is not a =
string and make a string from it.
I tried de # opertator
#define to_string( x ) # x
const char* VERSION =3D to_string( RELEASE_DATE );
but I get "RELEASE_DATE" and not "2005_11_11_-_11:11:11"
PS: sorry for sending this to your personal email... (new mail =
program.....)
=20
On 12/16/05, mi...@ne... <mi...@ne... > =
wrote:=20
How about trying
#define RELEASE_DATE "2005_11_11_-_11:11:11"
That makes the defined as a string.
Mike,
www.nanobit.net
=20
----- Original Message -----=20
From: Minds Work=20
To: dev...@li...=20
Sent: Friday, December 16, 2005 4:31 AM
Subject: [Dev-C++] Can I create a string from a non-string #define =
value??
=20
Hi
I have a #define like this:
#define RELEASE_DATE 2005_11_11_-_11:11:11
And I cannot change the value format :(
How can I create a string (char *) form the RELEASE_DATE define???
[]s
|