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

First time compilation error #77

Open
nagyj2 opened this issue Jul 24, 2021 · 2 comments
Open

First time compilation error #77

nagyj2 opened this issue Jul 24, 2021 · 2 comments

Comments

@nagyj2
Copy link

nagyj2 commented Jul 24, 2021

I downloaded munit and included the .c file in my sources and the header in my includes but when I went to compile, I got an error message saying "error: variably modified 'bytes' at file scope" and a few warnings. Here is a paste of the error message. I am on Intel MacOS 11.4 using C11 with GCC.

@codylico
Copy link

outsider comment; feel free to ignore

This kind of makes sense:

src/tests/munit.c:1836:47: warning: argument 4 of type 'char * const[argc + 1]' declared with mismatched bound 'argc + 1' [-Wvla-parameter]
 1836 |                         int argc, char* const argv[MUNIT_ARRAY_PARAM(argc + 1)],
      |                                   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/tests/munit.c:118:
./inc/munit.h:478:51: note: previously declared as 'char * const[argc + 1]' with bound 'argc + 1'
  478 |                             int argc, char* const argv[MUNIT_ARRAY_PARAM(argc + 1)],
      |                                       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

However, something concerning is this error message (the one you mention):

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Security.framework/Headers/Authorization.h:193:14: error: variably modified 'bytes' at file scope
  193 |         char bytes[kAuthorizationExternalFormLength];
      |              ^~~~~

This is actually coming from a macOS header, i.e. one not provided by or modified by munit. Based on
the kAuthorizationExternalFormLength documentation and a description of integer constant expressions required by fixed-size arrays, I would say the following:

  • Check again to ensure that the combination of compiler and operating system you listed is actually compatible. There may be Apple Clang features that handle kAuthorizationExternalFormLength in ways that GCC does not.
  • Check any additional compile-time parameters that may be interfering with compilation.
    I request that you follow up after doing so.

P.S. @nagyj2 May I confirm what you seem to state, that you're using macOS 11.4 (not 10.4)?

@HappySeaFox
Copy link

It looks like VLAs (variable-length arrays) are not supported in this particular GCC version for macOS. It also looks like the macOS headers assume that the compiler supports VLAs as char bytes[kAuthorizationExternalFormLength] is a VLA. I guess you won't be able to use this particular GCC version. Try to use a newer GCC version with VLA support in C11. In particular, __STDC_NO_VLA__ should not be defined by the compiler headers. If __STDC_NO_VLA__ is defined, the compiler doesn't support VLAs.

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

3 participants