Are you using the right macro?
Because this works for me...
dtest.c
Code:
#include <stdio.h>
int main( void ) {
#ifdef _SERVER_
printf( "Server started!\n" );
#else
printf( "Client started!\n" );
#endif
return 0;
}
Makefile
Code:
CC=gcc
CFLAGS=-O2
CLFILE=client.exe
SVFILE=server.exe
server:
$(CC) $(CFLAGS) -o $(SVFILE) -D_SERVER_ dtest.c
client:
$(CC) $(CFLAGS) -o $(CLFILE) dtest.c
clean:
rm client.exe
rm server.exe
rm dtest.o