[lammps-users] lammps 12mar11 on AIX - "PRId64" is not declared.

I am trying to compile a newer version of lammps on an AIX system.
I get errors for the different cpp files:

“PRId64” is not declared.

I checked for PRId64 and it seems that 6th of February there has been a change involving that parameter.
http://lammps.sandia.gov/patches/patch.6Feb11

Indeed, versions from 3th of February work fine.

Because of my restart files, I found I should be using an older version anyway, but does anyone know a fix for this?

Greetings, Pim

hi pim,

I am trying to compile a newer version of lammps on an AIX system.
I get errors for the different cpp files:

"PRId64" is not declared.

aaaaarrrrrggggghhhh!!!!
not again!

I checked for PRId64 and it seems that 6th of February there has been a
change involving that parameter.
http://lammps.sandia.gov/patches/patch.6Feb11

Indeed, versions from 3th of February work fine.

Because of my restart files, I found I should be using an older version
anyway, but does anyone know a fix for this?

i am probably to blame for this. this is _the_ most portable, cross-platform
way to print 64-bit integers, yet it looks like AIX (or at least your
version of it)
is not C99 standard compliant. :frowning:

if we change it back some other platform will break.
but if my (painful) experience from the past with AIX
serves me well, there might be a way to coax it into
doing the right thing.

can you tell us, what kind/version of machine and AIX you are on?
is it a recent or new one? has it been updated/maintained?

then can you play around a little with grep and dig through
the header file in /usr/include and its subdirectories,
if there is some file somewhere that has the string
PRId64 in it? or at least __STDC_FORMAT_MACROS?
you may also need to dig a little through the bundled
documentation for the compiler to see what is needed
to make it c99 compatible (it is by default probably only
compatible to some version from the stone age with
AIX specials enabled)

thanks,
    axel.

Ok as far as versions go I can discover the following:

in the xlc compiler help:

     IBM XL C/C\+\+ for AIX, V10\.1
     5724\-U81
     Copyright IBM Corp\. 1991, 2008\. All Rights Reserved\.

{schraven}\:/home/schraven>uname -a
AIX hlr0c 3 5 000132B2D900 powerpc unknown AIX

{schraven}\:/home/schraven>prtconf
System Model IBM,8204-E8A
Machine Serial Number: 65132B2
Processor Type: PowerPC_POWER6
Processor Implementation Mode: POWER 6
Processor Version: PV_6_Compat
Number Of Processors: 4
Processor Clock Speed: 4204 MHz
CPU Type: 64-bit
Kernel Type: 64-bit
LPAR Info: 1 HLR0C
Memory Size: 31744 MB
Good Memory Size: 31744 MB
Platform Firmware level: EL350_049
Firmware Version: IBM,EL350_049

I have no clue how up-to-date this is! Power6 seems recent enough, though.
Trying out options in AIX is not my favorite way to spend the day, and
I would be content enough using versions from before february 6th
2011, but I can try to take a look :slight_smile:

Greetings, Pim

There is an invocation of xlc with the name c99, but that doesn't seem
to be a parallel version.
I will try to go the other road instead.

ok, there is <inttypes.h> where both PRId64 are and the STDC thing are.

I already tried including #include <inttypes.h> it in the .cpp files
where the complaint was, but that didn't really help.
Shall I include it in other places as well?

{schraven}\:/usr/include>grep PRId64 *
inttypes.h:#define PRId64 "ld"
inttypes.h:#define PRId64 "lld"

{schraven}\:/usr/include>grep PRId64 *
inttypes.h:#define PRId64 "ld"
inttypes.h:#define PRId64 "lld"

great so there is hope.

all we need to know now is which #define is needed
to get the compiler to include the proper one of those defines.

on glibc/gcc this is wrapped in

/* The ISO C99 standard specifies that these macros must only be
   defined if explicitly requested. */
#if !defined __cplusplus || defined __STDC_FORMAT_MACROS

on AIX it may be something like -D_ANSI_SOURCE or -D_STDC_SOURCE
or -D_AIX_SOURCE

cheers,
    axel.

#if defined(__64BIT__)
#define PRId64 "ld"
#else
#if defined(_LONG_LONG)
#define PRId64 "lld"