Skip to content
New issue

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

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

Already on GitHub? # to your account

language-c and C11 support #4

Open
mitchty opened this issue Mar 6, 2016 · 7 comments
Open

language-c and C11 support #4

mitchty opened this issue Mar 6, 2016 · 7 comments

Comments

@mitchty
Copy link

mitchty commented Mar 6, 2016

Originally reported this to c2hs here and was noted that language-c is providing all of the usefulness: haskell/c2hs#159

Noticed on alpine linux 3.3.1 when compiling the ncurses package. Are there plans for language-c and C11 support? I know this pacage looks to just have changed ownership, and the haskell is a bit beyond my current ability at this point or I'd try to add a fix for the _Noreturn case I hit.

The error log:

Configuring ncurses-0.2.15...
Building ncurses-0.2.15...
Preprocessing library ncurses-0.2.15...
c2hs: C header contains errors:

/usr/include/stdlib.h:44: (column 11) [ERROR]  >>> Syntax error !
  The symbol `void' does not fit here.

And that section of stdlib.h:

_Noreturn void abort (void);
int atexit (void (*) (void));
_Noreturn void exit (int);
_Noreturn void _Exit (int);
int at_quick_exit (void (*) (void));
_Noreturn void quick_exit (int);

For now I just patch stdlib.h and remove the _Noreturn's to work around this:
https://github.com/mitchty/alpine-linux-ghc-bootstrap/blob/master/test-7.10/Dockerfile#L19

But I think a more general approach would be to have language-c start to support C11 constructs. I don't think full on generic support is really needed yet or anything from the appendices.

@visq
Copy link
Owner

visq commented Mar 8, 2016

So this particular problem would be fixed if language.c supports the _Noreturn function specifier (C11 6.7.4). Extending Lexer and Parser is trivial. However, the only other function specifier so far was inline, and because of this, function specifiers are not treated in an uniform way in Language.C. Supporting a second function specifier in a proper way will thus require some effort.

@visq
Copy link
Owner

visq commented Mar 16, 2016

In order to evaluate the changes necessary for proper C11 support, I reran gcc.dg test suite with language.c 0.5.0. The following (not necessarily complete) list of features needs to be implemented:

  • _Noreturn (implemented in HEAD, generalizing function specifiers)
  • _Alignas (alignment specifier)
  • _Thread_local (new keyword)
  • _Atomic (new qualifier)
  • static assertions
  • generic types

There are a couple of unsupported GNU extensions as well (e.g. auto types), but first aiming at C11 compatibility seems like a good idea. If an unsupported GNU extension is used in system headers, it should be prioritized as well.

@magnusjonsson
Copy link

I too would love to see C11 support, especially _Generic.

@evincarofautumn
Copy link

evincarofautumn commented Nov 28, 2016

I just encountered this issue with _Nonnull and _Nullable in the OS X 10.12 headers.

EDIT: It looks like these are extensions, not C11 features.

@arrowd
Copy link

arrowd commented Aug 30, 2017

Yes, _Nonnull is a Clang extension. It would be nice to support it, as FreeBSD headers also contain these decls.

@hasufell
Copy link

hasufell commented Aug 24, 2021

This issue still exists: vmchale/libarchive#12

Especially _Alignas.

@expipiplus1
Copy link
Collaborator

expipiplus1 commented Aug 25, 2021 via email

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

No branches or pull requests

7 participants