main.cpp compilation errors #7

Closed
opened 2026-10-05 03:52:50 +02:00 by adam · 9 comments
Owner

hi,

got some errors with gcc 4.3.1. used options: --enable-extra --disable-perl.
include paths are censored :-P


g++ -I/usr/xxx -I/usr/lxx -I/usr/xx/include -I/usr/xx/include -O3 -D_FORTIFY_SOURCE=2 -O2 -DHAVE_IPV6 -Wall -W -Wno-unused-parameter -Woverloaded-virtual -Wshadow -DHAVE_LSTAT -DHAVE_LIBSSL -D_MODULES -D_MODDIR_="/usr/local/znc/lib/znc" -D_DATADIR_="/usr/local/znc/share/znc" -c -o main.o main.cpp -MMD -MF .depend/main.o.dep
main.cpp:14: error: 'no_argument' was not declared in this scope
main.cpp:15: error: 'no_argument' was not declared in this scope
main.cpp:16: error: 'no_argument' was not declared in this scope
main.cpp:17: error: 'no_argument' was not declared in this scope
main.cpp:18: error: 'no_argument' was not declared in this scope
main.cpp:19: error: 'no_argument' was not declared in this scope
main.cpp:20: error: 'no_argument' was not declared in this scope
main.cpp:21: error: 'no_argument' was not declared in this scope
main.cpp:23: error: 'no_argument' was not declared in this scope
main.cpp:25: error: 'required_argument' was not declared in this scope
main.cpp:27: error: elements of array 'const option g_LongOpts []' have incomplete type
main.cpp:27: error: storage size of 'g_LongOpts' isn't known
main.cpp: In function 'int main(int, char**)':
main.cpp:96: error: 'getopt_long' was not declared in this scope

gmake: *** [main.o] Error 1

tried multiple versions down to 0.6.x. all had that error.
any help is welcome & thanks in advance :-)

hi, got some errors with gcc 4.3.1. used options: --enable-extra --disable-perl. include paths are censored :-P --- g++ -I/usr/xxx -I/usr/lxx -I/usr/xx/include -I/usr/xx/include -O3 -D_FORTIFY_SOURCE=2 -O2 -DHAVE_IPV6 -Wall -W -Wno-unused-parameter -Woverloaded-virtual -Wshadow -DHAVE_LSTAT -DHAVE_LIBSSL -D_MODULES -D_MODDIR_=\"/usr/local/znc/lib/znc\" -D_DATADIR_=\"/usr/local/znc/share/znc\" -c -o main.o main.cpp -MMD -MF .depend/main.o.dep main.cpp:14: error: 'no_argument' was not declared in this scope main.cpp:15: error: 'no_argument' was not declared in this scope main.cpp:16: error: 'no_argument' was not declared in this scope main.cpp:17: error: 'no_argument' was not declared in this scope main.cpp:18: error: 'no_argument' was not declared in this scope main.cpp:19: error: 'no_argument' was not declared in this scope main.cpp:20: error: 'no_argument' was not declared in this scope main.cpp:21: error: 'no_argument' was not declared in this scope main.cpp:23: error: 'no_argument' was not declared in this scope main.cpp:25: error: 'required_argument' was not declared in this scope main.cpp:27: error: elements of array 'const option g_LongOpts []' have incomplete type main.cpp:27: error: storage size of 'g_LongOpts' isn't known main.cpp: In function 'int main(int, char**)': main.cpp:96: error: 'getopt_long' was not declared in this scope ## gmake: **\* [main.o] Error 1 tried multiple versions down to 0.6.x. all had that error. any help is welcome & thanks in advance :-) <!-- github-sync-id:698936 -->
adam closed this issue 2026-10-05 03:52:51 +02:00
Author
Owner

Which system is this on? I'd guess this is Solaris 9 or worse because that's the only system that I know which is broken enough not to have getopt_long.
See http://en.znc.in/wiki/Portability

Which system is this on? I'd guess this is Solaris 9 or worse because that's the only system that I know which is broken enough not to have getopt_long. See http://en.znc.in/wiki/Portability <!-- github-comment-id:910093 -->
Author
Owner

hehe, irix actually

hehe, irix actually <!-- github-comment-id:910098 -->
Author
Owner

Added Irix to the "broken" list in the wiki. getopt_long is a GNU extension, so... yeah. But I really like long options. :-(

I googled a getopt_long implementation and the file has 540 lines. That's a lot.

So plan B:
Grab a text editor and edit main.cpp. Remove the "g_LongOpts" array in lines 13 to 27. In line 117/119, change the calls to getopt_long(argc, argv, , g_LongOpts, &iOptIndex) into getopt(arc, argv, ).

If you got any problems with that, tell me which version of znc you are looking at and I'll patch main.cpp for you. (And yes, this will remove support for long options like --foreground and --debug from znc and make only the short forms like -f and -D work).

Added Irix to the "broken" list in the wiki. getopt_long is a GNU extension, so... yeah. But I really like long options. :-( I googled a getopt_long implementation and the file has 540 lines. That's a lot. So plan B: Grab a text editor and edit main.cpp. Remove the "g_LongOpts" array in lines 13 to 27. In line 117/119, change the calls to getopt_long(argc, argv, <string>, g_LongOpts, &iOptIndex) into getopt(arc, argv, <string>). If you got any problems with that, tell me which version of znc you are looking at and I'll patch main.cpp for you. (And yes, this will remove support for long options like --foreground and --debug from znc and make only the short forms like -f and -D work). <!-- github-comment-id:911665 -->
Author
Owner

fantastic!!
will give it a try right away!
and i couldn't care less about long options anyway :-)

i'll try 0.096 first but wouldn't mind any other version either

fantastic!! will give it a try right away! and i couldn't care less about long options anyway :-) i'll try 0.096 first but wouldn't mind any other version either <!-- github-comment-id:912030 -->
Author
Owner

okay, that worked like a charm but one more issue came up:

Csocket.cpp: In function 'void __Perror(const CString&, const char*, unsigned int)':
Csocket.cpp:495: error: 'strerror_r' was not declared in this scope

okay, that worked like a charm but one more issue came up: Csocket.cpp: In function 'void __Perror(const CString&, const char*, unsigned int)': Csocket.cpp:495: error: 'strerror_r' was not declared in this scope <!-- github-comment-id:912230 -->
Author
Owner

http://predef.sourceforge.net/preos.html says that irix can be identified via #ifdef sgi, so could you change line 489 in Csocket.cpp from
#if defined(sun) || defined(_WIN32) || (defined(__NetBSD_Version) && NetBSD_Version < 4000000000)
into
#if defined(sgi) || defined(sun) || defined(_WIN32) || (defined(__NetBSD_Version) && NetBSD_Version < 4000000000)

http://predef.sourceforge.net/preos.html says that irix can be identified via `#ifdef sgi`, so could you change line 489 in Csocket.cpp from #if defined(**sun) || defined(_WIN32) || (defined(__NetBSD_Version**) && **NetBSD_Version** < 4000000000) into #if defined(sgi) || defined(**sun) || defined(_WIN32) || (defined(__NetBSD_Version**) && **NetBSD_Version** < 4000000000) <!-- github-comment-id:912708 -->
Author
Owner

that worked just as well as the solution before!
had to replace install.sh with a real one and all was fine. now i'm the proud owner of a nice and current znc package for irix :-)

i have to say this was the best support i got in years. normally it's like that: "what? not linux? don't care." :-P

and for what it's worth the patch:

--- main.cpp_O Thu Mar 24 17:15:38 2011
+++ main.cpp Thu Mar 24 14:02:17 2011
@@ -10,21 +10,6 @@
#include <getopt.h>
#include <sys/wait.h>

-static const struct option g_LongOpts[] = {

  •   { "help",        no_argument,       0, 'h' },
    
  •   { "version",     no_argument,       0, 'v' },
    
  •   { "debug",       no_argument,       0, 'D' },
    
  •   { "foreground",  no_argument,       0, 'f' },
    
  •   { "no-color",    no_argument,       0, 'n' },
    
  •   { "allow-root",  no_argument,       0, 'r' },
    
  •   { "makeconf",    no_argument,       0, 'c' },
    
  •   { "makepass",    no_argument,       0, 's' },
    

    -#ifdef HAVE_LIBSSL

  •   { "makepem",     no_argument,       0, 'p' },
    

    -#endif /* HAVE_LIBSSL */

  •   { "datadir",     required_argument, 0, 'd' },
    
  •   { 0, 0, 0, 0 }
    

    -};

    static void GenerateHelp(const char *appname) {
    CUtils::PrintMessage("USAGE: " + CString(appname) + " [options]");
    @@ -114,9 +99,9 @@
    #ifdef HAVE_LIBSSL
    bool bMakePem = false;

  •   while ((iArg = getopt_long(argc, argv, "hvnrcspd:Df", g_LongOpts, &iOptIndex)) != -1) {
    
  •   while ((iArg = getopt(argc, argv, "hvnrcspd:Df")) != -1) {
    

    #else

  •   while ((iArg = getopt_long(argc, argv, "hvnrcsd:Df", g_LongOpts, &iOptIndex)) != -1) {
    
  •   while ((iArg = getopt(argc, argv, "hvnrcsd:Df")) != -1) {
    

    #endif /* HAVE_LIBSSL */
    switch (iArg) {
    case 'h':

--- Csocket.cpp_O Thu Mar 24 17:15:38 2011
+++ Csocket.cpp Thu Mar 24 17:00:39 2011
@@ -487,7 +487,7 @@

void *Perror( const CS_STRING & s, const char pszFile, unsigned int iLineNo )
{
-#if defined(__sun) || defined(_WIN32) || (defined(__NetBSD_Version
) && NetBSD_Version < 4000000000)
+#if defined(sgi) || defined(sun) || defined(_WIN32) || (defined(__NetBSD_Version) && NetBSD_Version < 4000000000)
std::cerr << s << "(" << pszFile << ":" << iLineNo << "): " << strerror( GetSockError() ) << endl;
#else
char buff[512];

that worked just as well as the solution before! had to replace install.sh with a real one and all was fine. now i'm the proud owner of a nice and current znc package for irix :-) # i have to say this was the best support i got in years. normally it's like that: "what? not linux? don't care." :-P and for what it's worth the patch: --- main.cpp_O Thu Mar 24 17:15:38 2011 +++ main.cpp Thu Mar 24 14:02:17 2011 @@ -10,21 +10,6 @@ #include <getopt.h> #include <sys/wait.h> -static const struct option g_LongOpts[] = { - { "help", no_argument, 0, 'h' }, - { "version", no_argument, 0, 'v' }, - { "debug", no_argument, 0, 'D' }, - { "foreground", no_argument, 0, 'f' }, - { "no-color", no_argument, 0, 'n' }, - { "allow-root", no_argument, 0, 'r' }, - { "makeconf", no_argument, 0, 'c' }, - { "makepass", no_argument, 0, 's' }, -#ifdef HAVE_LIBSSL - { "makepem", no_argument, 0, 'p' }, -#endif /\* HAVE_LIBSSL */ - { "datadir", required_argument, 0, 'd' }, - ``` { 0, 0, 0, 0 } ``` -}; static void GenerateHelp(const char *appname) { CUtils::PrintMessage("USAGE: " + CString(appname) + " [options]"); @@ -114,9 +99,9 @@ #ifdef HAVE_LIBSSL bool bMakePem = false; - ``` while ((iArg = getopt_long(argc, argv, "hvnrcspd:Df", g_LongOpts, &iOptIndex)) != -1) { ``` - while ((iArg = getopt(argc, argv, "hvnrcspd:Df")) != -1) { #else - while ((iArg = getopt_long(argc, argv, "hvnrcsd:Df", g_LongOpts, &iOptIndex)) != -1) { - while ((iArg = getopt(argc, argv, "hvnrcsd:Df")) != -1) { #endif /\* HAVE_LIBSSL */ switch (iArg) { case 'h': --- Csocket.cpp_O Thu Mar 24 17:15:38 2011 +++ Csocket.cpp Thu Mar 24 17:00:39 2011 @@ -487,7 +487,7 @@ void **Perror( const CS_STRING & s, const char *pszFile, unsigned int iLineNo ) { -#if defined(__sun) || defined(_WIN32) || (defined(__NetBSD_Version**) && **NetBSD_Version** < 4000000000) +#if defined(sgi) || defined(**sun) || defined(_WIN32) || (defined(__NetBSD_Version**) && **NetBSD_Version** < 4000000000) std::cerr << s << "(" << pszFile << ":" << iLineNo << "): " << strerror( GetSockError() ) << endl; #else char buff[512]; <!-- github-comment-id:912936 -->
Author
Owner

So you do know that irix is dead since almost 5 years? Good. :-)

For the getopt_long problem I did a proper patch which has the same effect as the one you got, but with the difference that we still use getopt_long() if it is available:
http://git.znc.in/?p=psychon/znc.git;a=commitdiff;h=2afe2a77629012b24d8d270437e94e98d1657ffc

I'll forward the change to Csocket.cpp the right person.

So you do know that irix is dead since almost 5 years? Good. :-) For the getopt_long problem I did a proper patch which has the same effect as the one you got, but with the difference that we still use getopt_long() if it is available: http://git.znc.in/?p=psychon/znc.git;a=commitdiff;h=2afe2a77629012b24d8d270437e94e98d1657ffc I'll forward the change to Csocket.cpp the right person. <!-- github-comment-id:913056 -->
Author
Owner

hehe, i do, still love it tho (and the resp. machines).

thanks for all !!

hehe, i do, still love it tho (and the resp. machines). thanks for all !! <!-- github-comment-id:913124 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#7