Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stringify doesn't work ? #67

Open
massimosala opened this issue May 31, 2023 · 1 comment
Open

stringify doesn't work ? #67

massimosala opened this issue May 31, 2023 · 1 comment

Comments

@massimosala
Copy link

Python 3.8.10
pyclibrary just installed with pip


Sample header file:

#define MP_STRINGIFY(A) #A
#define MICROPY_VERSION_MAJOR 1
#define MICROPY_VERSION_MINOR 20
#define MICROPY_VERSION_MICRO 0
#define MICROPY_VERSION_STRING MP_STRINGIFY(MICROPY_VERSION_MAJOR) "." MP_STRINGIFY(MICROPY_VERSION_MINOR) "." MP_STRINGIFY(MICROPY_VERSION_MICRO)

I process the file with

parser = CParser(filename)
parser.process_all()
print(parser.defs["values"])

The output is

{'MICROPY_VERSION_MAJOR': 1, 'MICROPY_VERSION_MINOR': 20, 'MICROPY_VERSION_MICRO': 0, 'MICROPY_VERSION_STRING': None}

Problem: MICROPY_VERSION_STRING isn't evaluated.

I tried also with this definition

#define MP_STRINGIFY(A) str(A)
#define str(A) #A

Please, can you help me to solve it?

@massimosala
Copy link
Author

Addendum

Parsing the file with MP_STRINGIFY, I get this warning

:1: SyntaxWarning: 'tuple' object is not callable; perhaps you missed a comma?

Is 1 the line number?
These are the first lines of the real file...

/*
 * This file is part of the MicroPython project, http://micropython.org/
 *
 * The MIT License (MIT)

Second observation.
Looking at fnmacros I see

fnmacros {'str': ('#{}', [0]), 'MP_STRINGIFY': ('#{}', [0]), etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant