schrodinger / pymol-open-source

Open-source foundation of the user-sponsored PyMOL molecular visualization system.
https://pymol.org/
Other
1.2k stars 281 forks source link

layer1/Basis.h:42:3: error: expected ‘}’ before numeric constant #186

Closed sagitter closed 3 years ago

sagitter commented 3 years ago

Hi all.

pymol-2.5.0 is not compiling in Fedora 34 (GCC-11.1.1, Python-3.9) with following errors:

g++ -pthread -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -std=c++11 -fPIC -D_PYMOL_LIBPNG -D_PYMOL_FREETYPE -DPYMOL_OPENMP -D_PYMOL_VMD_PLUGINS -D_HAVE_LIBXML -DMMTF_MSGPACK_USE_CPP11 -D_PYMOL_NUMPY -Iinclude -Icontrib/uiuc/plugins/include -Iov/src -Ilayer0 -Ilayer1 -Ilayer2 -Ilayer3 -Ilayer4 -Ilayer5 -Ibuild/generated -Icontrib/uiuc/plugins/molfile_plugin/src -Icontrib/mmtf-c -I/usr/lib64/python3.9/site-packages/numpy/core/include -I/usr/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/python3.9 -c -MMD layer3/Seeker.cpp -o build/temp.linux-x86_64-3.9/layer3/Seeker.o -Werror=return-type -Wunused-variable -Wno-switch -Wno-narrowing -Wno-char-subscripts -O2 -fopenmp
layer3/Seeker.cpp: In function ‘void SeekerRefresh(PyMOLGlobals*, std::vector<CSeqRow>&)’:
layer3/Seeker.cpp:485:20: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
  485 |   for(int b = 0; b < nRow; b++) {
      |                  ~~^~~~~~
layer3/Seeker.cpp: In function ‘void SeekerUpdate(PyMOLGlobals*)’:
layer3/Seeker.cpp:1150:23: warning: comparison of integer expressions of different signedness: ‘ov_size’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
 1150 |           if(row->len < min_pad) {
      |              ~~~~~~~~~^~~~~~~~~
layer3/Seeker.cpp:1186:23: warning: comparison of integer expressions of different signedness: ‘ov_size’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
 1186 |           if(row->len < min_pad) {
      |              ~~~~~~~~~^~~~~~~~~
layer3/Seeker.cpp: In lambda function:
layer3/Seeker.cpp:1248:30: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
 1248 |             for(int i = 0; i < str_size; i++){
      |                            ~~^~~~~~~~~~
layer3/Seeker.cpp: In function ‘void SeekerUpdate(PyMOLGlobals*)’:
layer3/Seeker.cpp:1930:27: warning: comparison of integer expressions of different signedness: ‘ov_size’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
 1930 |           if(row->ext_len < stop)
      |              ~~~~~~~~~~~~~^~~~~~
In file included from layer0/vla.h:7,
                 from layer1/Symmetry.h:26,
                 from layer1/PyMOLObject.h:27,
                 from layer1/Seq.h:21,
                 from layer3/Seeker.cpp:26:
layer3/Seeker.cpp: In function ‘void SeekerFree(PyMOLGlobals*)’:
layer0/MemoryDebug.h:86:32: warning: deleting object of polymorphic class type ‘CSeeker’ which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]
   86 | #define DeleteP(ptr) {if(ptr) {delete ptr;ptr=NULL;}}
layer3/Seeker.cpp:1964:3: note: in expansion of macro ‘DeleteP’
 1964 |   DeleteP(G->Seeker);
      |   ^~~~~~~
In file included from /usr/include/X11/Xlib.h:44,
                 from /usr/include/GL/glx.h:30,
                 from layer5/main.cpp:38:
layer1/Basis.h:42:3: error: expected identifier before numeric constant
   42 |   None = 0,
      |   ^~~~
layer1/Basis.h:42:3: error: expected ‘}’ before numeric constant
In file included from layer1/Ray.h:24,
                 from layer1/Rep.h:21,
                 from layer2/AtomInfo.h:22,
                 from layer1/P.h:21,
                 from layer5/main.cpp:50:
layer1/Basis.h:41:20: note: to match this ‘{’
   41 | enum class cCylCap {
      |                    ^
In file included from /usr/include/X11/Xlib.h:44,
                 from /usr/include/GL/glx.h:30,
                 from layer5/main.cpp:38:
layer1/Basis.h:42:3: error: expected unqualified-id before numeric constant
   42 |   None = 0,
      |   ^~~~
In file included from layer1/Ray.h:24,
                 from layer1/Rep.h:21,
                 from layer2/AtomInfo.h:22,
                 from layer1/P.h:21,
                 from layer5/main.cpp:50:
layer1/Basis.h:45:1: error: expected declaration before ‘}’ token
   45 | };
      | ^
In file included from /usr/include/X11/Xlib.h:44,
                 from /usr/include/GL/glx.h:30,
                 from layer5/main.cpp:38:
layer1/Basis.h:48:39: error: expected unqualified-id before numeric constant
   48 | constexpr auto cCylCapNone = cCylCap::None;
      |                                       ^~~~
In file included from layer1/Ray.h:24,
                 from layer1/Rep.h:21,
                 from layer2/AtomInfo.h:22,
                 from layer1/P.h:21,
                 from layer5/main.cpp:50:
layer1/Basis.h:49:39: error: ‘Flat’ is not a member of ‘cCylCap’
   49 | constexpr auto cCylCapFlat = cCylCap::Flat;
      |                                       ^~~~
layer1/Basis.h:50:40: error: ‘Round’ is not a member of ‘cCylCap’
   50 | constexpr auto cCylCapRound = cCylCap::Round;
      |                                        ^~~~~
layer5/main.cpp: In function ‘int MainCreateWindow(const char*)’:
layer5/main.cpp:885:24: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  885 |       hint->res_name = "pymol";
      |                        ^~~~~~~
layer5/main.cpp:886:25: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  886 |       hint->res_class = "Pymol";
      |                         ^~~~~~~
In file included from layer1/Ray.h:24,
                 from layer1/Rep.h:21,
                 from layer2/AtomInfo.h:22,
                 from layer1/P.h:21,
                 from layer5/main.cpp:50:
layer1/Basis.h: At global scope:
layer1/Basis.h:50:16: warning: ‘cCylCapRound’ defined but not used [-Wunused-variable]
   50 | constexpr auto cCylCapRound = cCylCap::Round;
      |                ^~~~~~~~~~~~
layer1/Basis.h:49:16: warning: ‘cCylCapFlat’ defined but not used [-Wunused-variable]
   49 | constexpr auto cCylCapFlat = cCylCap::Flat;
      |                ^~~~~~~~~~~
layer1/Basis.h:48:16: warning: ‘cCylCapNone’ defined but not used [-Wunused-variable]
   48 | constexpr auto cCylCapNone = cCylCap::None;
      |                ^~~~~~~~~~~
layer4/Cmd.cpp: In function ‘PyObject* CmdPushUndo(PyObject*, PyObject*)’:
layer4/Cmd.cpp:2216:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
 2216 |     if(ok)
      |     ^~
layer4/Cmd.cpp:2218:7: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
 2218 |       if(s0[0])
      |       ^~
layer4/Cmd.cpp: In function ‘PyObject* CmdGetMinMax(PyObject*, PyObject*)’:
layer4/Cmd.cpp:4469:7: warning: variable ‘ok’ set but not used [-Wunused-but-set-variable]
 4469 |   int ok = false;
      |       ^~
In file included from layer4/Cmd.cpp:77:
layer1/PConv.h: In instantiation of ‘PyObject* PConvToPyObject(const std::array<_Tp, _Nm>&) [with T = float; long unsigned int N = 3; PyObject = _object]’:
layer4/Cmd.cpp:380:27:   required from ‘PyObject* APIResult(PyMOLGlobals*, pymol::Result<T>&) [with T = std::array<float, 3>; PyObject = _object]’
layer4/Cmd.cpp:4034:19:   required from here
layer1/PConv.h:259:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
  259 |   for (int i = 0; i < N; ++i) {
      |                   ~~^~~
JarrettSJohnson commented 3 years ago

Looks like a name conflict because of raw macros in Xlib.h. There's tons of other projects out there that have experienced the same issue. :(

Looks like you're not compiling with -D_PYMOL_NO_MAIN. Are you compiling with --glut?

sagitter commented 3 years ago

Looks like you're not compiling with -D_PYMOL_NO_MAIN. Are you compiling with --glut?

Yes, but it fails without --glut, too.

sagitter commented 3 years ago

Is not there any chance to fix these errors?

JarrettSJohnson commented 3 years ago

This is ultimately something that Xlib needs to fix, but in the meantime, something like

#ifdef None
#undef None
#endif

above where we define our own None can likely fix it, but I don't have a system where I can reproduce this error to be sure.

sagitter commented 3 years ago

Hi @JarrettSJohnson

I don't know what i'm doing but your suggestion is working:

--- a/layer1/Basis.orig.h   2021-05-10 20:38:37.000000000 +0200
+++ b/layer1/Basis.h    2021-10-05 20:07:14.567410004 +0200
@@ -38,6 +38,10 @@

 */

+#ifdef None
+#undef None
+#endif
+
 enum class cCylCap {
   None = 0,
   Flat = 1,

Here the full build log.

JarrettSJohnson commented 3 years ago

Thanks for giving it a shot. I'll commit to master in just a bit.