using macros in a GLUT function

Hello everyone!

I got a question:
I want to use a macro in a GLUT function, i.a.:
#define CURRENT_DATE (23. May 2002)
and want to use it within the glutCreateWindow();
How to use it? My compiler won’t allow me
glutCreateWindow("Current date is: "CURRENT_DATE);
I can’t find any information about it…

please help me!

Moritz

Howsabout …

#include <stdio.h>
#include <time.h>

int main(int argc, char **argv)
{
time_t t;
char c;
int w;
t = time(NULL);
c = (char
)malloc(45*sizeof(char));
sprintf(c, “Current date is: %s”,asctime(localtime(&t)));
w = glutCreateWindow©;
}

Rob.

Thanx for that… I’ll have to try it!

Moritz

[This message has been edited by Moritz (edited 05-25-2002).]

Hmm… the idea is good, but my realisation isn’t that “efficiant”.
May you could help me again. (BTW: I don’t need the date of compilation, I just need the date of the source release.)

So here’s my source:

#include <stdio.h>
#include <string.h>
#include <gl/glut.h>

#define BUILD “0001”
#define BUILD_DATE “23.05.2002”

void main(void)
{
char window_name[45]
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

strcpy (window_name, "Project One - Build: “);
strcat (window_name, BUILD);
strcat (window_name, " [”);
strcat (window_name, BUILD_DATE);
strcat (window_name, “]”);

glutCreateWindow(window_name);
//…
//…
}

Is there any way to use C++ instead of C? Any faster way?
BTW: It currently works! My window name is "Project one - Build 0001 [23.05.2002]

But it looks quit unefficiant :frowning:

Moritz

If your using mfc you can use CString:

CString str;
str = "Project One - Build: ";
str += BUILD;
str += BUILD_DATE;

there are other ways. but you basically have
it right. I’d suggest bumping the char array
up to 100 bytes or so so you never overwrite it.

regards,
Jim