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

__VA_ARGS__ broken in g++: badly punctuated parameter list in `#define' #8

Open
sezero opened this issue Aug 1, 2017 · 5 comments
Open

Comments

@sezero
Copy link

sezero commented Aug 1, 2017

$ cat test.c
#include <proto/dos.h>

$ m68k-amigaos-g++ -O2 -Wall -c test.c
In file included from /opt/m68k-amigaos/lib/gcc-lib/m68k-amigaos/2.95.3/../../../../m68k-amigaos/include/../ndk/include/proto/dos.h:13,
                 from test.c:1:
/opt/m68k-amigaos/lib/gcc-lib/m68k-amigaos/2.95.3/../../../../m68k-amigaos/include/../ndk/include/inline/dos.h:157: badly punctuated parameter list in `#define'
/opt/m68k-amigaos/lib/gcc-lib/m68k-amigaos/2.95.3/../../../../m68k-amigaos/include/../ndk/include/inline/dos.h:262: badly punctuated parameter list in `#define'
/opt/m68k-amigaos/lib/gcc-lib/m68k-amigaos/2.95.3/../../../../m68k-amigaos/include/../ndk/include/inline/dos.h:271: badly punctuated parameter list in `#define'
/opt/m68k-amigaos/lib/gcc-lib/m68k-amigaos/2.95.3/../../../../m68k-amigaos/include/../ndk/include/inline/dos.h:372: badly punctuated parameter list in `#define'
/opt/m68k-amigaos/lib/gcc-lib/m68k-amigaos/2.95.3/../../../../m68k-amigaos/include/../ndk/include/inline/dos.h:453: badly punctuated parameter list in `#define'
/opt/m68k-amigaos/lib/gcc-lib/m68k-amigaos/2.95.3/../../../../m68k-amigaos/include/../ndk/include/inline/dos.h:570: badly punctuated parameter list in `#define'
/opt/m68k-amigaos/lib/gcc-lib/m68k-amigaos/2.95.3/../../../../m68k-amigaos/include/../ndk/include/inline/dos.h:687: badly punctuated parameter list in `#define'

Relevant part of inline/dos.h, around line 157:

#ifndef NO_INLINE_STDARG
#define AllocDosObjectTags(___type, ___tags, ...) \
    ({_sfdc_vararg _tags[] = { ___tags, __VA_ARGS__ }; AllocDosObjectTagList((___type), (const struct TagItem *) _tags); })
#endif /* !NO_INLINE_STDARG */
@cahirwpz
Copy link
Member

cahirwpz commented Jan 14, 2018

According to "Badly punctuated parameter list in #define" blog post, the problem could be fixed by replacing:

#define AllocDosObjectTags(___type, ___tags, ...) \
    ({_sfdc_vararg _tags[] = { ___tags, __VA_ARGS__ }; AllocDosObjectTagList((___type), (const struct TagItem *) _tags); })

... with:

#define AllocDosObjectTags(___type, ___tags, ARGS...) \
    ({_sfdc_vararg _tags[] = { ___tags, ##ARGS }; AllocDosObjectTagList((___type), (const struct TagItem *) _tags); })

This could be achieved by modifying function_start in sfdc.

@adtools adtools deleted a comment from sezero Jan 14, 2018
@cahirwpz
Copy link
Member

cahirwpz commented Jan 14, 2018

Another quick fix is to pass -Wp,-std=gnu9x to g++ which makes sure C++ compiler uses "more recent" preprecessor features. As __VA_ARGS__ works with newer C++ standard I'm in favour of not changing sfdc, but rather supplying default option to the preprocessor when running in C++ mode (-lang-c++ option). However I'd have to reach out to C++ guys to verify if such a change won't break something fundamentally.

EDIT: I could modify -lang-c++ settings with opts->c9x = 1.

@cahirwpz
Copy link
Member

@sezero Any opinion on that topic? I'm leaning towards latter option.

@sezero
Copy link
Author

sezero commented Jan 20, 2018

-Wp,-std=gnu9x (but not -std=gnu9x alone) does workaround the issue
for me.

@sezero
Copy link
Author

sezero commented Apr 5, 2022

Applied your suggested change to my fork as sezero@53b3955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants