Ticket #29 (new defect)

Opened 2 years ago

Last modified 2 years ago

C2HS chokes on Mac "^" block notation

Reported by: guest Owned by:
Priority: normal Milestone:
Component: general Version: 0.16.0
Keywords: Cc:

Description

on Snow Leopard, /usr/include/stdlib.h contains Apple's new blocks notation, which c2hs seems unhappy with, despite it being protected by an #ifdef.

lines 271 onwards:

#ifdef BLOCKS int atexit_b(void ()(void)); void *bsearch_b(const void *, const void *, size_t,

size_t, int ()(const void *, const void *));

#endif /* BLOCKS */

➜ hubris-0.0.2 ./Setup build Preprocessing library hubris-0.0.2... c2hs: C header contains errors:

/usr/include/stdlib.h:272: (column 20) [ERROR] >>> error

Syntax error ! The symbol `' does not fit here.

Change History

Changed 2 years ago by guest

eesh, that ate my formatting.

C code:

#ifdef __BLOCKS__
int      atexit_b(void (^)(void));
void    *bsearch_b(const void *, const void *, size_t,
            size_t, int (^)(const void *, const void *));
#endif /* __BLOCKS__ */

result from running c2hs:

➜  hubris-0.0.2  ./Setup build   
Preprocessing library hubris-0.0.2...
c2hs: C header contains errors:

/usr/include/stdlib.h:272: (column 20) [ERROR]  >>> error
  Syntax error !
  The symbol `^' does not fit here.\

Changed 2 years ago by duncan

Does undefining BLOCKS help?

Otherwise we're going to have to extend language-c to parse this extension.

Changed 2 years ago by guest

undefining BLOCKS does not help, I'm pretty sure that language-c will need to be extended.

As a quick workaround, you can specify to use cpp-4.0 and it seems to work:

c2hs -ccpp-4.0

on my machine cpp-4.0 seems to actually be gcc-4.0.1

Changed 2 years ago by guest

Undefining BLOCKS doesn't help but undefining BLOCKS does (note the underscores). Regardless, Language.C should probably support the blocks notation, I've filed  Ticket 2 to that effect.

Changed 2 years ago by guest

__BLOCKS__, I mean. Damn wiki formatting.

Note: See TracTickets for help on using tickets.