[tlbuild] build failure: duplicated extern "C" definition of getopt() when compiling a C++ program
Vladimir Volovich
vvv at vsu.ru
Mon Jun 7 00:10:22 CEST 2010
"KB" == Karl Berry writes:
KB> I feel sure that every system we compile on declares getopt() by
KB> now. So I removed the non-__STDC__ decl of getopt from
KB> kpathsea/getopt.h.
thanks.
KB> It still seems wrong to me, in principle, for a compiler to
KB> complain about a declaration like getopt() -- such a traditional C
KB> declaration is supposed to match anything, as far as I know.
apparently even GCC is strict in this area:
$ cat test.cpp
extern "C" {
int getopt(int argc, char * const argv[], const char *optstring);
}
extern "C" {
int getopt();
}
$ g++ -c test.cpp
test.cpp:6: error: declaration of C function ‘int getopt()’ conflicts with
test.cpp:2: error: previous declaration ‘int getopt(int, char* const*, const char*)’ here
Best,
v.
More information about the tlbuild
mailing list