0.10.0-beta2-rc1 getopt problems on Solars 9

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

0.10.0-beta2-rc1 getopt problems on Solars 9

Douglas E. Engert
gcc 3.3.2 reports conflicting types for 'my_getopt'
in pkcs11-tool.c

The Solaris 9 stdio.h, stdlib.h and unistd.h all have:

     extern int getopt(int, char *const *,const char *);

The line:
     #define getopt my_getopt
in ./common/getopt.h can cause the getopt in in these system
header files to be redefines as my_getopt this conflicts with the
delcaration of:
     extern int my_getopt(int, char * argv[], const char *opts);
in ./common/my_getopt.h

So the order of the header files is important.
./util/util.h includes the getopt.h before the std*.h files,
causing the problem.
Some of the programs also include the getopt.h, util.h and std*.h
in various orders.

I also see that #include <getopt.h> in some files is not
#ifdef'ed.







--

  Douglas E. Engert  <[hidden email]>
  Argonne National Laboratory
  9700 South Cass Avenue
  Argonne, Illinois  60439
  (630) 252-5444
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: 0.10.0-beta2-rc1 getopt problems on Solars 9

Douglas E. Engert
See possible fix below.

Douglas E. Engert wrote:

> gcc 3.3.2 reports conflicting types for 'my_getopt'
> in pkcs11-tool.c
>
> The Solaris 9 stdio.h, stdlib.h and unistd.h all have:
>
>     extern int getopt(int, char *const *,const char *);
>
> The line:
>     #define getopt my_getopt
> in ./common/getopt.h can cause the getopt in in these system
> header files to be redefines as my_getopt this conflicts with the
> delcaration of:
>     extern int my_getopt(int, char * argv[], const char *opts);
> in ./common/my_getopt.h
>
> So the order of the header files is important.
> ./util/util.h includes the getopt.h before the std*.h files,
> causing the problem.
> Some of the programs also include the getopt.h, util.h and std*.h
> in various orders.
>
> I also see that #include <getopt.h> in some files is not
> #ifdef'ed.
>
>

--- ,pkcs11-tool.c Thu Oct  6 13:51:40 2005
+++ pkcs11-tool.c Tue Oct 11 14:17:22 2005
@@ -21,7 +21,6 @@
  #ifdef HAVE_CONFIG_H
  #include <config.h>
  #endif
-#include <getopt.h>

  #include <opensc/pkcs11.h>
  #include "util.h"



--- ,util.h Thu Sep 15 17:03:08 2005
+++ util.h Tue Oct 11 14:16:16 2005
@@ -4,9 +4,6 @@
  #ifdef HAVE_CONFIG_H
  #include <config.h>
  #endif
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
@@ -19,6 +16,9 @@
  #include <unistd.h>
  #endif
  #include <sys/stat.h>
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
  #include <opensc/opensc.h>

  #ifdef __cplusplus




--

  Douglas E. Engert  <[hidden email]>
  Argonne National Laboratory
  9700 South Cass Avenue
  Argonne, Illinois  60439
  (630) 252-5444
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: 0.10.0-beta2-rc1 getopt problems on Solars 9

Andreas Jellinghaus-2
In reply to this post by Douglas E. Engert
Hi Douglas,

if I understand the issue right, we have two problems:
a) solaris has getopt. the opensc configure checks for
   getopt long and defines HAVE_GETOPT_LONG only if
   it is found. can you check if it was found?
   it should be, but I guess it was not.
b) we either need to put all #include <getopt.h> into
   a #ifdef HAVE_GETOPT_LONG or modify our copy of
   getopt.h to do nothing if HAVE_GETOPT_LONG is defined.
 
maybe we did b) earlier (check for HAVE_GETOPT_LONG in
the getopt.h file) and it was lost when we migrated to
the non gpl code.

Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: 0.10.0-beta2-rc1 getopt problems on Solars 9

Douglas E. Engert


Andreas Jellinghaus wrote:

> Hi Douglas,
>
> if I understand the issue right, we have two problems:
> a) solaris has getopt. the opensc configure checks for
>    getopt long and defines HAVE_GETOPT_LONG only if
>    it is found. can you check if it was found?
>    it should be, but I guess it was not.

Solaris 9 does not have a getopt_long, and does not
have a getopt.h  Only defines in the std*.h files for
the getopt function.

Solaris 10 does have a getopt.h, with getopt and getopt_long.
with a comment "GNU-like getopt_long(), getopt_long_only()"


> b) we either need to put all #include <getopt.h> into
>    a #ifdef HAVE_GETOPT_LONG or modify our copy of
>    getopt.h to do nothing if HAVE_GETOPT_LONG is defined.
>  
> maybe we did b) earlier (check for HAVE_GETOPT_LONG in
> the getopt.h file) and it was lost when we migrated to
> the non gpl code.
>
> Andreas
>
>

--

  Douglas E. Engert  <[hidden email]>
  Argonne National Laboratory
  9700 South Cass Avenue
  Argonne, Illinois  60439
  (630) 252-5444
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: 0.10.0-beta2-rc1 getopt problems on Solars 9

Andreas Jellinghaus-2
In reply to this post by Douglas E. Engert
On Tuesday 11 October 2005 21:31, Douglas E. Engert wrote:
> See possible fix below.

thanks, applied.

hmm, I still don't entirely get the code:
what happends on a system without getopt.h?
it might not work at all: if none of the
system headers has getopt_long, I don't see
anything that will the one we ship.

but maybe I'm missing some part.

Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel