Wed Sep 01 2010 6:14:03 am EDT EDT from samjam @ Uncensored Subject: Re: macro "strncmp" requires 3 arguments, but only 2 given

 

Wed Sep 01 2010 6:06:48 am EDT EDT from dothebart @ Uncensored Subject: Re: macro "strncmp" requires 3 arguments, but only 2 given

HKEY is a macro that does

a, sizeof(a) - 1

so it actualy has 3 parameters. Maybe for some reason that macro isn't visible to your compiler there?

that strncmp actualy wants to check for the first two chars.

To be clear to my other reply, on my system strcmp and strncmp are macros and so HKEY won't work to return more than one parameter



You can do the HKEY trick on vararg macros:

cat <<END > x.c

#define strncmp(a,b,c) [a][b][c]
#define _strncmp(...) strcmp(__VA_ARGS__)
#define HKEY(a) a, (sizeof(a)-1)
_strncmp("something", HKEY("__"));
x.c

gcc -E x.c

# 1 "x.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "x.c"

["something"]["__"][(sizeof("__")-1)];

But on my system strncmp isn't a vararg macro.

Reply via email to