Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"'opt*' redeclared without dllimport attribute: previous dllimport ignored" warnings in Cygwin #710

Closed
Rangi42 opened this issue Jan 21, 2021 · 3 comments · Fixed by #728
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM

Comments

@Rangi42
Copy link
Contributor

Rangi42 commented Jan 21, 2021

When I make rgbds in Cygwin x64 on Windows 8.1, it gives these warnings:

$ make
DEFS=-Dlr.type=ielr -Dparse.lac=full -Dparse.error=verbose
In file included from src/asm/main.c:33:
include/extern/getopt.h:29:14: warning: ‘optarg’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   29 | extern char *optarg;
      |              ^~~~~~
include/extern/getopt.h:30:12: warning: ‘optind’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   30 | extern int optind, opterr, optopt, optreset;
      |            ^~~~~~
include/extern/getopt.h:30:20: warning: ‘opterr’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   30 | extern int optind, opterr, optopt, optreset;
      |                    ^~~~~~
include/extern/getopt.h:30:28: warning: ‘optopt’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   30 | extern int optind, opterr, optopt, optreset;
      |                            ^~~~~~
include/extern/getopt.h:30:36: warning: ‘optreset’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   30 | extern int optind, opterr, optopt, optreset;
      |                                    ^~~~~~~~
In file included from src/extern/getopt.c:36:
include/extern/getopt.h:29:14: warning: ‘optarg’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   29 | extern char *optarg;
      |              ^~~~~~
include/extern/getopt.h:30:12: warning: ‘optind’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   30 | extern int optind, opterr, optopt, optreset;
      |            ^~~~~~
include/extern/getopt.h:30:20: warning: ‘opterr’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   30 | extern int optind, opterr, optopt, optreset;
      |                    ^~~~~~
include/extern/getopt.h:30:28: warning: ‘optopt’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   30 | extern int optind, opterr, optopt, optreset;
      |                            ^~~~~~
include/extern/getopt.h:30:36: warning: ‘optreset’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   30 | extern int optind, opterr, optopt, optreset;
      |                                    ^~~~~~~~

(For some reason they don't come up regarding every instance of #include "extern/getopt.h".)

@ISSOtm
Copy link
Member

ISSOtm commented Feb 10, 2021

This is because we're re-implementing getopt. Dunno if/how this could be fixed, barring renaming all the symbols, which I'd like to avoid.

@ISSOtm ISSOtm added bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM labels Feb 10, 2021
@pinobatch
Copy link
Member

I renamed all the symbols when I imported a snapshot of this getopt reimplementation into my own project. See musl_getopt.c in pinobatch/little-things-nes.

@Rangi42
Copy link
Contributor Author

Rangi42 commented Feb 10, 2021

Renaming all the symbols avoids any dependency on the ones declared by unistd.h. It also makes extern/getopt.c actually used, and thus checked by checkpatch.

(I had tried different combinations of declaring or not declaring some variables as extern, but nothing (a) gave no warnings on Cygwin and (b) compiled on all platforms.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbasm This affects RGBASM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants