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

Cannot compile pugixml #66

Closed
chrisUHD opened this issue Nov 12, 2015 · 17 comments
Closed

Cannot compile pugixml #66

chrisUHD opened this issue Nov 12, 2015 · 17 comments

Comments

@chrisUHD
Copy link

Hey,
I tried to use pugixml for my current project but I am not able to compile it. Three errors occur:

..\pugixml-1.7\src\pugixml.cpp: In function 'long long int pugi::impl::{anonymous}::get_value_llong(const char_t*)':
..\pugixml-1.7\src\pugixml.cpp:4454:91: error: 'LLONG_MIN' was not declared in this scope
   return string_to_integer<unsigned long long>(value, 0 - static_cast<unsigned long long>(LLONG_MIN), LLONG_MAX);
                                                                                           ^
..\pugixml-1.7\src\pugixml.cpp:4454:103: error: 'LLONG_MAX' was not declared in this scope
   return string_to_integer<unsigned long long>(value, 0 - static_cast<unsigned long long>(LLONG_MIN), LLONG_MAX);
                                                                                                       ^
..\pugixml-1.7\src\pugixml.cpp: In function 'long long unsigned int pugi::impl::{anonymous}::get_value_ullong(const char_t*)':
..\pugixml-1.7\src\pugixml.cpp:4459:58: error: 'ULLONG_MAX' was not declared in this scope
   return string_to_integer<unsigned long long>(value, 0, ULLONG_MAX);

Maybe you encountered this problem before.

Best Regards

Chris

@hobbes1069
Copy link

It's helpful to provide information about your environment. I would think at a minimum: What distro are you running? gcc version? i686 or x86_64?

@zeux
Copy link
Owner

zeux commented Nov 12, 2015

Please also specify the full command line that you use for compiling pugixml, in addition to the exact version of whatever compiler you're using (if you're using gcc or clang you can get it via 'gcc -v' or 'clang -v')

@chrisUHD
Copy link
Author

Sorry, totally forgot. You are right, i used an older 32 bit mingw compiler.

@zeux
Copy link
Owner

zeux commented Nov 12, 2015

What's the specific version? I generally try to make pugixml compatible across all MinGW versions.

This error implies that limits.h is pre-C99. Since you're using MinGW it's probably detected as MSVC and thus is trying to use long long. I think I tested MinGW versions down to 3.4 but I'll double check.

@chrisUHD
Copy link
Author

Should have been MinGW 32 bit Version 3.8 but it seems like there was something else wrong. I got it running now with MinGW nuwen 4.0 64 bit. I also had to enable C++11 support in Eclipse. Thanks for your help!

@zeux
Copy link
Owner

zeux commented Nov 13, 2015

As far as I can tell this is essentially an issue in MinGW 3.8.

My distributions of MinGW 3.4 and MinGW 4+ all have the following guards for LLONG_MIN/etc. declarations:

#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
     || !defined(__STRICT_ANSI__)

So regardless of STRICT_ANSI mode (activated automatically when you specify -std= option) you'll get the definitions.

MinGW 3.8 headers I can find on SourceForge do something else:

#if !defined(__STRICT_ANSI__) && defined(__GNUC__)

Which is very wrong (violates C99 standard). Here's a thread with the same issue AFAICT: http://compgroups.net/comp.lang.c/long-long/711656

@zeux
Copy link
Owner

zeux commented Nov 13, 2015

Based on this thread maybe this is not even related to the version of MinGW as much as the distribution - looks like the headers can come from different packages or something. Why is this such a mess :-/

@zeux
Copy link
Owner

zeux commented Nov 13, 2015

Ok, MinGW does not define _MSC_VER. I can sort-of reproduce this by building with these buggy headers from SourceForge if I specify -DPUGIXML_HAS_LONG_LONG explicitly - if I don't I can't reproduce this since I can't use -std=c++11 (compiler is too old for that). So you must have had a pretty recent MinGW compiler (C++11-aware) with headers that don't know about LLONG_MAX in strict ANSI mode (not C++11-aware).

@zeux zeux closed this as completed in 2cf599b Nov 13, 2015
@chrisUHD
Copy link
Author

As you pointed out correctly the problem is not only dependent on the MinGW Version. I was playing around with different distros (nuwen, 64bit and so on). I will look into the issue further when I got time, as I would like to use the nuwen distro. Thanks

@zeux
Copy link
Owner

zeux commented Nov 16, 2015

Since I have applied the workaround in 2cf599b, you should be able to use the latest master without issues.

@seatedscribe
Copy link

I just stumbled on the same error here. Didn't dig into the problem, but resolved including instead of <limits.h> in pugixml.cpp. compiler is GCC 6.3.0 built from sources myself. Strange enough, this problem disappears using default OS compiler (Ubuntu 5.4.0).

Any hint about how to provide more insightful data for you to process?

@seatedscribe
Copy link

seatedscribe commented Oct 12, 2017

Doh, for some reason github postprocessing cuts out my "climits" inside brackets but I think you get the point... :)

@zeux
Copy link
Owner

zeux commented Oct 12, 2017

@seatedscribe Would you mind uploading the limits.h file that pugixml.cpp includes somewhere so that I can take a look at it? You can get the precise path by compiling pugixml with -MD flag, e.g.

gcc pugixml.cpp -c -MD && cat pugixml.d | grep limits

@zeux
Copy link
Owner

zeux commented Oct 12, 2017

I also had a report before about pugixml not compiling correctly on a custom-built GCC but in that case the headers installed by gcc were just broken - specifically, assert.h installed to /usr/local/include/asset.h couldn't be compiled for whatever reason.

@seatedscribe
Copy link

seatedscribe commented Oct 13, 2017

Well, compiler throws the error so it doesn't produce any output file.
I tried with -H and the only interesting file is located at use/local/lib/GCC/x86_64-pc-linux-gnu/6.3.0/include-fixed/limits.h. I will upload if you think could help.

Only way is compiling with climits header, but I guess it's not what you want.
How can we get the include path then?

@zeux
Copy link
Owner

zeux commented Oct 13, 2017

Ah right, -MD requires the compilation to succeed :( If that's the case you could use -E in a similar fashion:

gcc pugixml.cpp -E | grep limits.h

@seatedscribe
Copy link

seatedscribe commented Oct 19, 2017

That command worked.
I confirm the path of the file is
/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include-fixed/limits.h

I will upload it tomorrow, but the name of folder is quite odd :/

@zeux zeux mentioned this issue Feb 22, 2018
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

4 participants