LFortran installation problem

I just tried installing LFortran from the latest tarball (0.17) but when I run make -j8, I get the following error:

In file included from /home/grishkin/lfortran-0.17.0-11-g36f3f4875/src/libasr/codegen/asr_to_wasm.cpp:11:
/home/grishkin/lfortran-0.17.0-11-g36f3f4875/src/libasr/…/libasr/codegen/wasm_assembler.h:129:5: error: use of undeclared identifier ‘assert’

assert(num.size() <= 4);
^
1 error generated.

I have checked and wasm_assembler.h has cassert included at the start.

The default compiler was gcc 12 so I tried using clang but got the same result.

Thanks for the report. What platform are you on? Linux? x86 or arm? 64bit?

It should build, so we’ll have to debug this. You can also try the latest git version.

I am on Ubuntu 22.10 64-bit.

I also tried the git version - same error.

Try commenting that one assert line, and see if it continues. We test Ubuntu at our CI and everything works, so it must be some slight incompatibility with our CI setup and your local setup. If you manage to fix it, please send us a PR!

Is it possibly useful to try to compile something like

// mytest.cpp
#include <cassert>
int main()
{
    int x = 1;
    assert( x == 1 );
}

as

$ g++-12 -E mytest.cpp | grep assert

# 1 "/usr/include/c++/12/cassert" 1 3
# 41 "/usr/include/c++/12/cassert" 3
# 42 "/usr/include/c++/12/cassert" 3
# 44 "/usr/include/c++/12/cassert" 2 3
# 1 "/usr/include/assert.h" 1 3 4
# 66 "/usr/include/assert.h" 3 4
...

or similarly

$ clang++ mytest.cpp | grep assert

? One possibility might be that there are some other assert.h in the include path that interferes with the desired one. For example, if I put “assert.h” in the current directory like

// ./assert.h
/* foo */

I get an error

$ g++-12 -I. mytest.cpp
mytest.cpp: In function ‘int main()’:
mytest.cpp:7:5: error: ‘assert’ was not declared in this scope
    7 |     assert( x == 1 );
      |     ^~~~~~

In the case of clang, the error message becomes like this (similar to OP)

$ clang++ -I. mytest.cpp 
mytest.cpp:7:5: error: use of undeclared identifier 'assert'
    assert( x == 1 );
    ^
1 Like