Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Macro preprocessing error from g++ and clang++ #211

Closed
oroppas opened this issue Feb 18, 2017 · 3 comments
Closed

Macro preprocessing error from g++ and clang++ #211

oroppas opened this issue Feb 18, 2017 · 3 comments

Comments

@oroppas
Copy link

oroppas commented Feb 18, 2017

g++ (6.3.1) and clang++ (3.9.1), I've got

/home/ryuta/packages/pyjion/src/pyjion-git/Pyjion/taggedptr.h:60:10: error: pasting "*" and "tmpIn" does not give a valid preprocessing token
  PyObject* ##name = init_number(tmp_##name, value);
          ^
/home/ryuta/packages/pyjion/src/pyjion-git/Pyjion/intrins.cpp:2445:9: note: in expansion of macro ‘INIT_TMP_NUMBER’
         INIT_TMP_NUMBER(tmpIn, UNTAG_IT(inI));
         ^~~~~~~~~~~~~~~
        size_t tmp_tmpIn[(((sizeof(PyVarObject) + sizeof(uint32_t) * ((((sizeof(tagged_ptr) * 8) - 1) + 30 - 1) / 30)) / sizeof(size_t)) + sizeof(size_t))]; PyObject*tmpIn = init_number(tmp_tmpIn, ((inI) >> 1));;
        *out = PyLong_AsDouble(tmpIn);
    }
    else {
        *out = PyLong_AsDouble(in);
    }
    return *out == -1.0 && PyErr_Occurred();
}

PyObject* ##name = init_number(tmp_##name, value);

get preprocessed to

PyObject*tmpIn = init_number(tmp_tmpIn, ((inI) >> 1))

## of ##name in PyObject* ##name = init_number(tmp_##name, value); should be removed.
Is this change valid? I don't have a Windows machine to check this change won't break the build.

@brettcannon
Copy link
Member

Won't removing ## break the macro, though, since e.g. tmpIn won't exist but instead simply be name? (And sorry about the late response; been on holiday.)

@tonybaloney
Copy link
Contributor

Implemented in #237

@oroppas
Copy link
Author

oroppas commented Nov 14, 2020

Thank you, @tonybaloney

@oroppas oroppas closed this as completed Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants