The compiler often knows details about the target machine, so you can use conditional compilation to have one piece of code for big endian processors and another for little endian processors. That keeps the code from being bloated with code that's designed for a different processor.
A similar case is when you have assembly code for one particular system but C code for other systems.