Skip to content

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

@angerhang

Description

@angerhang

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++) { ..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions