HPCE / hpce-2017-cw6

2 stars 17 forks source link

understanding use of USE_LONGLONG #7

Closed guigzzz closed 7 years ago

guigzzz commented 7 years ago

I've been trying to figure out how to start optimising the code. When looking at the code, I often see this preprocessor directive. By pure curiosity I wanted to see how it was defined: It is apparently defined in testu01/include/gdef.h: image HAVE_LONGLONG which is checked in the first line of my screenshot, is unconditionally defined as being 1 in testu01/include/gdefconf.h This seems weird to me as the directives seem to define USE_LONGLONG twice, once in the ifdef HAVE_LONGLONG, and once again unconditionally on line 47 of my screenshot. As a consequence it would seem that defining the same thing twice doesn't present any problem to the compiler (or I'm reading the code incorrectly). What I also don't understand is why USE_LONGLONG is needed in this case if the directive is going to be defined without checking that the compiler/host actully supports 64bit integers. Is this inherited code from the C version of this library? Or is there something that I am missing here?

m8pple commented 7 years ago

Yes, this is inherited from the C version, which uses GNU autotools to manage configuration. So the normal C build version is the standard:

./configure     # Make config.h and gdefconfig.h
make              # Actually build it

For the purposes of the coursework I tried to get something static that would work "most places", so tried to restrict it to a common set of choices.

So I punted that everyone would be using a compiler where long long is 64-bit - I'm not sure of any modern production x86 compiler where that isn't true, so it seemed a safe choice.