Comments (5)
Someone reported the clang-cl bug in https://bugs.llvm.org/show_bug.cgi?id=48904 and I just fixed it. The fix will be in LLVM 12.0.
(/me waves at @fingolfin -- hey Max, long time no see :))
from minlzma.
Latest clang
(at least on Linux) seems to compile static_assert
just fine as long as assert.h
is added and you use --std=c11
:
ionescu@DESKTOP-TBH09DR:$ clang -c xzstream.c
In file included from xzstream.c:32:
./xzstream.h:67:15: error: expected parameter declarator
static_assert(sizeof(XZ_STREAM_HEADER) == 12, "Invalid Stream Header Size");
ionescu@DESKTOP-TBH09DR$
Compare with:
ionescu@DESKTOP-TBH09DR$ clang -c xzstream.c --std=c11
ionescu@DESKTOP-TBH09DR$
The CMakeFile enforces this:
set_target_properties(minlz_obj PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED YES C_EXTENSIONS NO)
from minlzma.
You're right. I was incorrect and while _Static_assert
is a C11 keyword static_assert
is available in <assert.h>
. I misread some docs trying to figure out what was going on. My bad!
However LLVM for Windows does not compile static_assert
in this project
clang -c lzmadec.c -std=c11
lzmadec.c:576:5: error: expected expression
static_assert((LZMA_BIT_MODEL_SLOTS * 2) == sizeof(g_Decoder.BitModel), "Invalid size");
It does compile a simple case:
#include <assert.h>
static_assert(sizeof(int) == sizeof(int), "Invalid size");
But it doesn't compile a slightly different simple case:
#include <assert.h>
int test()
{
static_assert(sizeof(int) == sizeof(int), "uh");
}
clang -c test.c -std=c11
test.c:5:5: error: expected expression
static_assert(sizeof(int) == sizeof(int), "uh");
This seems like a very strange compiler bug! It may make sense to move
static_assert((LZMA_BIT_MODEL_SLOTS * 2) == sizeof(g_Decoder.BitModel), "Invalid size");
From inside the body of LzInitialize to a higher scope.
from minlzma.
So this library then requires C11? Pity, unfortunately for now I am stuck with C99 (not my choice).
Perhaps this is something that could be pointed in the README?
from minlzma.
from minlzma.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minlzma.