Issue 23871 - ImportC: __attribute not recognized
Summary: ImportC: __attribute not recognized
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Linux
: P1 enhancement
Assignee: No Owner
URL:
Keywords: ImportC, pull
Depends on:
Blocks:
 
Reported: 2023-04-30 17:16 UTC by naydef
Modified: 2023-05-02 04:07 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description naydef 2023-04-30 17:16:52 UTC
main.d
----------------
import xawd;

void main()
{

}
----------------

xawd.c
----------------
#include <X11/Intrinsic.h>
----------------

Errors:
----------------
/usr/include/X11/Intrinsic.h(1729): Error: no type-specifier for parameter
/usr/include/X11/Intrinsic.h(1733): Error: no type-specifier for parameter
/usr/include/X11/Intrinsic.h(1753): Error: missing comma or semicolon after declaration of `XtAppErrorMsg`, found `__attribute` instead
/usr/include/X11/Intrinsic.h(1762): Error: missing comma or semicolon after declaration of `XtErrorMsg`, found `__attribute` instead
/usr/include/X11/Intrinsic.h(1785): Error: no type-specifier for parameter
/usr/include/X11/Intrinsic.h(1789): Error: no type-specifier for parameter
/usr/include/X11/Intrinsic.h(1804): Error: missing comma or semicolon after declaration of `XtAppError`, found `__attribute` instead
/usr/include/X11/Intrinsic.h(1808): Error: missing comma or semicolon after declaration of `XtError`, found `__attribute` instead
----------------

For the first error:
----------------
extern XtErrorMsgHandler XtAppSetErrorMsgHandler(
    XtAppContext 	/* app_context */,
    XtErrorMsgHandler 	/* handler */ _X_NORETURN //line 1729
);
----------------
It seems it's caused by _X_NORETURN. The other errors are also caused by it, it seems.

For the error on line 1753:
----------------
extern void XtAppErrorMsg(
    XtAppContext 	/* app_context */,
    _Xconst _XtString 	/* name */,
    _Xconst _XtString	/* type */,
    _Xconst _XtString	/* class */,
    _Xconst _XtString	/* default */,
    String*		/* params */,
    Cardinal*		/* num_params */
) _X_NORETURN; //line 1753
----------------


_X_NORETURN seems to be defined like this:
-----------------
/* requires xproto >= 7.0.17 */
#if __has_attribute(noreturn) \
    || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
    || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define _X_NORETURN __attribute((noreturn))
#else
# define _X_NORETURN
#endif /* GNUC  */
-----------------

It seems __attribute((noreturn)) is not recognized.

Using DMD64 D Compiler v2.103.0
Comment 1 Dlang Bot 2023-05-02 00:22:50 UTC
@WalterBright created dlang/dmd pull request #15160 "fix Issue 23871 - ImportC: __attribute not recognized" fixing this issue:

- fix Issue 23871 - ImportC: __attribute not recognized

https://github.com/dlang/dmd/pull/15160
Comment 2 Dlang Bot 2023-05-02 04:07:04 UTC
dlang/dmd pull request #15160 "fix Issue 23871 - ImportC: __attribute not recognized" was merged into master:

- d9686e153fe35aaf101e841930c820b7e41ace7e by Walter Bright:
  fix Issue 23871 - ImportC: __attribute not recognized

https://github.com/dlang/dmd/pull/15160