Results 1 to 4 of 4
Hello:
How can I write a C preprocessor macro that is mapped to syslog versus fprintf depending on the OS.
For instance,
On Linux map to this.
syslog(LOG_xyx, "STUFF %s ...
- 09-17-2009 #1Just Joined!
- Join Date
- Oct 2006
- Posts
- 22
C Preprocessor Macro for syslog/fprintf
Hello:
How can I write a C preprocessor macro that is mapped to syslog versus fprintf depending on the OS.
For instance,
On Linux map to this.
syslog(LOG_xyx, "STUFF %s %d %x", str, avar, bvar);
On Windows map to this. :
fprintf(file, "STUFF %s %d %x", str, avar, bvar);
Thanks,
--B
- 09-18-2009 #2Just Joined!
- Join Date
- Mar 2008
- Location
- Chennai, India
- Posts
- 26
#ifdef LINUX
#define macro(x,y,z,a,b) syslog(x, y, z, a, b);
#else
#define macro(x,y,z,a,b) fprintf(x, y, z, a, b);
#endif
Check this and do keep us posted.
For reference, you can look into "The Complete C Reference- H.Schildt"
cheers,
Sarma
- 09-18-2009 #3Just Joined!
- Join Date
- Oct 2006
- Posts
- 22
Hi:
I am worried about the variable arguments list. I don't want to have a different macro for every different combination of args to the syslog / printf.
Any other suggestions.
Thanks,
--B
- 09-18-2009 #4Just Joined!
- Join Date
- Mar 2008
- Location
- Chennai, India
- Posts
- 26


Reply With Quote
