atf icon indicating copy to clipboard operation
atf copied to clipboard

tp_test.c: fix compilation on Solaris

Open grobian opened this issue 6 years ago • 10 comments

On Solaris, getopt(3) is in stdio.h.

grobian avatar Dec 16 '17 07:12 grobian

I have the impression the travis failures are due to AS_ROOT=yes. I can't see an obvious error in the buildlogs, but I may not know where to look.

grobian avatar Dec 16 '17 08:12 grobian

@grobian: I disagree, per the current Solaris spec: https://docs.oracle.com/cd/E86824_01/html/E54766/getopt-3c.html . Is Solaris compiling with non-POSIX mode enabled?

ngie-eign avatar Mar 08 '19 18:03 ngie-eign

I assumed you wouldn't want that, as that would require trickery with either the C-standard or _POSIX_SOURCE feature tests, which on Solaris requires you to do it correctly, else you get an error. Just including stdio.h seemed safer and less hassle ;)

grobian avatar Mar 08 '19 18:03 grobian

I assumed you wouldn't want that, as that would require trickery with either the C-standard or _POSIX_SOURCE feature tests, which on Solaris requires you to do it correctly, else you get an error. Just including stdio.h seemed safer and less hassle ;)

Not really. Adding AC_USE_SYSTEM_EXTENSIONS to configure.ac would do the trick IMHO.

ngie-eign avatar Mar 08 '19 18:03 ngie-eign

worth a shot

grobian avatar Mar 08 '19 18:03 grobian

atf-c/tp_test.c: In function ‘atfu_getopt_body’:
atf-c/tp_test.c:59:18: error: implicit declaration of function ‘getopt’; did you mean ‘gettxt’? [-Werror=implicit-function-declaration]
     while ((ch = getopt(argc, argv, ":Z")) != -1) {
                  ^~~~~~
                  gettxt
atf-c/tp_test.c:67:17: error: ‘optopt’ undeclared (first use in this function)
             if (optopt != 's')
                 ^~~~~~
atf-c/tp_test.c:67:17: note: each undeclared identifier is reported only once for each function it appears in
In file included from ./atf-c.h:30,
                 from atf-c/tp_test.c:31:
atf-c/tp_test.c:73:34: error: ‘optind’ undeclared (first use in this function)
     ATF_REQUIRE_EQ_MSG(1, argc - optind, "Invalid number of arguments left "
                                  ^~~~~~
./atf-c/macros.h:132:15: note: in definition of macro ‘ATF_REQUIRE_MSG’
         if (!(expression)) \
               ^~~~~~~~~~
atf-c/tp_test.c:73:5: note: in expansion of macro ‘ATF_REQUIRE_EQ_MSG’
     ATF_REQUIRE_EQ_MSG(1, argc - optind, "Invalid number of arguments left "
     ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:2642: atf-c/tp_test-tp_test.o] Error 1

The reason for this is obviously because atf-c/tp_test.c doesn't include config.h. Adding the include next to AC_USE_SYSTEM_EXTENSIONS makes the utility compile.

So it's either those changes, or addition of stdio.h as in my original patch.

grobian avatar Mar 11 '19 12:03 grobian

@googlebot rescan

(Mass-triggering a rescan of all open PRs as I have just configured automated CLA checks but the bot won't go through the backlog on its own.)

jmmv avatar Mar 14 '19 10:03 jmmv

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

googlebot avatar Mar 14 '19 10:03 googlebot

Hey @grobian ! I think adding config.h to the file and the autoconf magic is the right thing to do in this case. If you do that, I can take the change. Thanks!

ngie-eign avatar Feb 22 '24 03:02 ngie-eign

@ngie-eign is this what you had in mind?

grobian avatar Feb 23 '24 09:02 grobian