Code Monkey home page Code Monkey logo

Comments (5)

nico avatar nico commented on August 18, 2024 4

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.

ionescu007 avatar ionescu007 commented on August 18, 2024

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.

Honeybunch avatar Honeybunch commented on August 18, 2024

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.

fingolfin avatar fingolfin commented on August 18, 2024

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.

ionescu007 avatar ionescu007 commented on August 18, 2024

from minlzma.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.