This idea product a new way to generate PC/pyconfig.h:
Now you have this c.in file.
#ifndef Py_CONFIG_H
#define Py_CONFIG_H
// ...
#undef HAVE_XXX
#undef HAVE_YYY
#undef SIZEOF_ZZZ
#endif
Then write a configure.toml:
[analyse.bool]
macro = "HAVE_XXX"
header = ["example1.h"]
code = """
int main() {
xxx();
return 0;
}
"""
store_value = "fail or not"
[analyse.bool]
macro = "HAVE_YYY"
header = ["example2.h"]
code = """
int main() {
yyy();
return 0;
}
"""
store_value = "fail or not"
[analyse.number]
macro = "SIZEOF_ZZZ"
header = ["stdio.h"]
code = """
int main() {
printf("%d\n", sizeof(zzz));
return 0;
}
"""
store_value = "output"
The configure.bat will analyse this toml file.
There will be three modes: bool, number and string
For bool, it will only store 1 or just keep the comment of /*#undef XXX*/.
For number, it will store the result of something (recommend “output”).
For string, the final macro value will be enclosed by double quotes (recommend “output”).