Suppose you’ve written a portable C++ code which runs smoothly on different platforms. To make some modifications to optimize performance, you use inline assembly inside your code. Is it a good practice (compiler optimization set aside) or will it make troubles for portability?
Suppose you’ve written a portable C++ code which runs smoothly on different platforms. To
Share
Obviously the inline assembly isn’t even close to portable. To maintain any portability at all, you generally have to use an
#ifdef(or something on that order) to determine when to use it at all.My own preference is to segregate the assembly language into a separate file, and in the makefile decide whether to build the portable version or the assembly language version.