Well, does anyone have a link to some documentation that explain how to make my code work on both? What do I have to do to my code to make sure it works on both 64bit and 32bit machines?
Well, does anyone have a link to some documentation that explain how to make my code work on both? What do I have to do to my code to make sure it works on both 64bit and 32bit machines?
If you don't make invalid assumptions about size of data types, you don't need to do anything. Your code should already work on both.
Most common mistakes by far is assuming pointers are 4 bytes (assigning pointers to/from integral types) and ints are 4 bytes (though this is true on some 64-bit architectures for compatibility).
Never assign pointers to integral types or integral types to pointers. They are never guaranteed to be same size.
If you want a variable of a specific size, use fixed width types in stdint.h. Eg. int32_t, uint32_t, int64_t, uint64_t.
Oh, okay. It's that simple. Thanks for your reply.
You wouldn't have an answer to my other stupid question, would you?
How come C can be cross-processor/architecture, but ASM can't?
Different computer architectures will require different assembly code, for a program. Allowing code to be compiled in C for any architecture, by it's own C compiler, was one of the big breakthroughs for the C language.
You might picture ASM as a beautiful (verbal) language, but it's only known to one country's people. Nobody else speaks it, so nobody can translate it. C, on the other hand, always has a (human) interpreter (in the form of the compiler) - so it's language can be made understandable, for any country.
I program microprocessors and I can tell you a good reason to program stuff in C rather than assembly - Not all assembly languages are the same. If I want to use subroutine/functions that I've developed on a AVR on a PIC I can, even though they have COMPLETELY different Assembly languages.
For all the things that are device specific (writing to registers to set up interrupts or reading analogue ports), you use the pre-processor commands.
Another thing that may be an issue are writing to output ports that exist on one device, but not the other.Code:#if defined(__18F8722) #pragma config ... /* Clear the peripheral interrupt flags */ PIR1 = 0; // Enable interrupt priority RCONbits.IPEN = 1; // Make receive interrupt high priority // USART enabled in init_usart() IPR1bits.RCIP = 1; /* Enable the timer interrupt */ PIE1bits.TMR2IE = 1; IPR1bits.TMR2IP = 0; // Enable all high priority interrupts INTCONbits.GIEH = 1; // Enable all low priority interrupts INTCONbits.GIEL = 1; #elif defined(PIC18F46J50_PIM) #pragma config #elif defined(...) #pragma config .. #endif
Basically, the way you get around this is by defining outputs in a config file the same way as above.
So... RunPE is able to compile an EXE and have that same compiled EXE run on different Windows machines?