QStrings

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
p-i-
Posts: 20
Joined: Sun Sep 14, 2014 2:24 pm

QStrings

Post by p-i- » Sat Sep 20, 2014 7:23 pm

I have copied /py/* into my C++ project.

I get a preprocessor error in QStr.h:

Code: Select all

enum {
    MP_QSTR_NULL = 0, // indicates invalid/no qstr
    MP_QSTR_ = 1, // the empty qstr
#define Q(id, str) MP_QSTR_##id,
#include "genhdr/qstrdefs.generated.h" <-- here
#undef Q
    MP_QSTR_number_of,
};
Could someone explain what is happening? It looks as though different QStrings are needed for different platforms. But why?

What would be the best way to address this?

π

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: QStrings

Post by dhylands » Sat Sep 20, 2014 9:14 pm

That's a generated file.

If you go into the unix directory and do make clean followed by make V=1 then you'll see something like the following:

Code: Select all

542 >make V=1
mkdir -p build/genhdr
CPP ../py/qstrdefs.h
gcc -E -I. -I../py -Ibuild -Wall -Werror -ansi -std=gnu99 -DUNIX -DMICROPY_USE_READLINE=1 -DMICROPY_PY_TIME=1 -DMICROPY_PY_TERMIOS=1   -DMICROPY_PY_FFI=1 -Os   ../py/qstrdefs.h -o build/genhdr/qstrdefs.preprocessed.h
makeqstrdata ../py/qstrdefs.h qstrdefsport.h
python ../py/makeqstrdata.py build/genhdr/qstrdefs.preprocessed.h qstrdefsport.h > build/genhdr/qstrdefs.generated.h
../py/py-version.sh > build/genhdr/py-version.h.tmp
...
The Makefile rules which invoke this are found here: https://github.com/micropython/micropyt ... #L130-L136

qstr's are basically what's referred to as interned strings: http://en.wikipedia.org/wiki/String_interning

p-i-
Posts: 20
Joined: Sun Sep 14, 2014 2:24 pm

Re: QStrings

Post by p-i- » Sun Sep 21, 2014 12:11 pm

For now I have just done the UNIX build and copied /unix/build/genhdr/qstrdefs.generated.h across.

Post Reply