catch22 icon indicating copy to clipboard operation
catch22 copied to clipboard

Installation failure: `for’ loop initial declarations are only allowed in C99 mode`

Open angerhang opened this issue 3 years ago • 0 comments

When running pip install catch22, the C compilation seems to complain. I tried it with python 3.7-3.9.

 C/CO_AutoCorr.c:531:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
             for(int j = 0; j < numBins; j++){
             ^
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/cxx579/anaconda3/envs/test_env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l6lnk30h/catch22_0230d4e651e84fa1a6f4489c53513e34/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l6lnk30h/catch22_0230d4e651e84fa1a6f4489c53513e34/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-g8rdn06o/install-record.txt --single-version-externally-managed --compile --install-headers /home/cxx579/anaconda3/envs/test_env/include/python3.9/catch22 Check the logs for full command output.

I am not an expert in C and how it tights up with the Python wrapper but it might. have to do with this? Any ideas how to fix this. Thx :D

This issue can be fixed by

export CFLAGS="-std=c99"

However, it might be good to change the for loop instantiation that is more compatible by declaring the the iteration variable outside the loop like:

int i;
for (i=0;i<10;i++) { ..

angerhang avatar Nov 18 '21 11:11 angerhang