This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: _testembed.c fails to compile when using --with-cxx-main in the configure step
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.8, Python 3.7
Status: closed Resolution: duplicate
Dependencies: Superseder: Failed to build with --with-cxx-main=g++-9.2.0
View: 39697
Assigned To: Nosy List: ericvw, pablogsal, remi.lapeyre, vstinner
Priority: normal Keywords:

Created on 2019-02-06 14:45 by pablogsal, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg334942 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-02-06 14:45
Programs/_testembed.c is compiled with $(MAINCC) in and that will use the C++ compiler if --with-cxx-main is used in the configuration step. The problem is that if the C++ compiler used is some of the more uncommon ones (like the solaris compiler) some parts of _testembed.c and its includes fail to compile because they are assuming C99 or compiler extension. There are mainly two:

1) _testembed.c has gotos that crosses variable definitions. The C++ standard says:

If transfer of control enters the scope of any automatic variables (e.g. by jumping forward over a declaration statement), the program is ill-formed (cannot be compiled), unless all variables whose scope is entered have

1) scalar types declared without initializers
2) class types with trivial default constructors and trivial destructors declared without initializers
3) cv-qualified versions of one of the above
4) arrays of one of the above

So the gotos that can be found in `dump_config_impl` in `_testembed.c` are invalidating this rule.

2) `testembed.c` is pulling `pystate.h` and that header file defines a macro (_PyCoreConfig_INIT) that uses designated initializers that are not available as an extension in all C++ compilers.

The solutions that I can immediately think of aare:

1) Compile _testembed.c with the $(CC) instead of $(CCMAIN).
2) Change these files to make them compliant with the standard (by initializing all variables at the beginning and by using just compound literals).
msg363244 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-03 09:08
Duplicate of bpo-39697.
Date User Action Args
2022-04-11 14:59:10adminsetgithub: 80093
2020-03-03 09:08:31vstinnersetstatus: open -> closed

superseder: Failed to build with --with-cxx-main=g++-9.2.0

nosy: + vstinner
messages: + msg363244
resolution: duplicate
stage: resolved
2019-02-09 13:34:43remi.lapeyresetnosy: + remi.lapeyre
2019-02-09 12:58:51ericvwsetnosy: + ericvw
2019-02-06 14:45:32pablogsalcreate