compiling on 64bit systems

Is it possible to compile the same source code on 32bit and 64bit systems?

I'm trying to compile OpenLDAP on AIX 5.3 64 bit with gcc but I get a memory fault when sarting it and I think it is caused by a 32bit vs 64bit problem.

Yes *if*

  1. the code supports a 64bit environment and
  2. the code detects the appropriate defines, for example "_LP64".
  3. doesn't make silly assumptions about length of "long", see 1 and 2.
  4. all libraries that it needs are available in 64 bit mode.

I've used gcc on DEC-Alpha, 64 bit UltraSparc-II and 64 bit PA-Risc-2 without problem, also gcc is used by Apple for 64 bit G5 Macintoshes.

64 bit AIX uses dual shared libraries which contain both 32 bit code(shr.o) and 64 bit code(shr64.o), so the link should fail if the correct type is not available.