ISO C++ standard?


HarryKane
05-16-2008, 08:47 AM
Hi,

I included the nr3.h and get some annoying error messages.
> g++ main.cc -o program -pedantic
nr3.h:477: error: ISO C++ does not support ‘long long’
nr3.h:478: error: ISO C++ does not support ‘long long
I thought the code is conform with the ANSI/ISO C++ standard (Introduction 1.03), or am I wrong?

Bill Press
05-16-2008, 10:02 AM
Good question! Generally, NR3 is ISO compliant. You've found an exception that occurs in Section 7.1, where good random number generators absolutely positively must use 64 bit integers! The problem is that there is no ISO standard type name for such integers, even though all modern compilers have them. Thus, in nr3.h, the lines

#ifdef _MSC_VER
typedef __int64 Llong; // 64 bit integer
typedef unsigned __int64 Ullong;
#else
typedef long long int Llong; // 64 bit integer
typedef unsigned long long int Ullong;
#endif

These cover the conventions for g++ and MSVC++, but are not stictly ISO. If you have a compiler with different type names, you'll need to modify nr3.h.

Cheers,
Bill P.

davekw7x
05-16-2008, 12:14 PM
G...The problem is that there is no ISO standard type name for such integers, even though all modern compilers have them...

With g++ versions 3.4.xxx and 4.xxx.xxx to which I have access (various Linux platforms and and Windows XP platforms with GNU/cygwin), here's what works for me:

Leave all of the NR3 distribution files alone and just don't use the '-pedantic' switch with g++. I strongly recommend that you do use '-Wall -W' switches.

Regards,

Dave

HarryKane
05-20-2008, 09:13 AM
Leave all of the NR3 distribution files alone and just don't use the '-pedantic' switch with g++. I strongly recommend that you do use '-Wall -W' switches.Now I desist from the '-pedantic' switch, but I was using it mostly, because it teached me to be more accurate while programming :D