Skip to content

Errors on const pointer declarations and #define preprocessor declarations #227

@bordenc

Description

@bordenc

I'm using ctypesgen on VideoLAN's libdvdread library. It's throwing the following errors:

ERROR: .../libdvdread/src/dvdread/bitreader.h:31: Syntax error at '*'
ERROR: .../libdvdread/src/dvdread/bitreader.h:36: Syntax error at '*'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:452: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:479: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:486: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:492: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:501: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:502: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:510: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:568: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:577: Syntax error at '\n'
ERROR: /usr/include/x86_64-linux-gnu/sys/cdefs.h:604: Syntax error at '\n'

The offending parts of code in bitreader.h are:

typedef struct {
  const uint8_t *start;  /* line 31 */
  uint32_t byte_position;
  uint32_t bit_position;
} getbits_state_t;

DVDREAD_API int dvdread_getbits_init(getbits_state_t *state, const uint8_t *start); /* line 36 */

From what I can tell, the const uint8_t * declaration in each of those lines upsets ctypesgen. However, this appears to be perfectly correct C.

The offending lines in /usr/include/x86_64-linux-gnu/sys/cdefs.h are:

# define __attribute_malloc__ __attribute__ ((__malloc__))  /* line 452 */
# define __attribute_pure__ __attribute__ ((__pure__))  /* line 479 */
# define __attribute_const__ __attribute__ ((__const__))  /* line 486 */
# define __attribute_maybe_unused__ __attribute__ ((__unused__))  /* line 492 */
# define __attribute_used__ __attribute__ ((__used__))  /* line 501 */
# define __attribute_noinline__ __attribute__ ((__noinline__))  /* line 502 */
# define __attribute_deprecated__ __attribute__ ((__deprecated__))  /* line 510 */
# define __returns_nonnull __attribute__ ((__returns_nonnull__)) /* line 568 */
# define __attribute_warn_unused_result__ \
   __attribute__ ((__warn_unused_result__)) /* lines 577 & 578 */
# define __attribute_artificial__ __attribute__ ((__artificial__)) /* line 604 */

The only thing that looks problematic about these defines are the space between the # and define. Is this some sort of "extension" in GNUC where I need to set a flag?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions