It is said in the FAQ section of Raspbian that the following tags are the only ones required when compiling.
I dunno what ancient FAQ that was; also compiler flags are one of those things that are easily used and abused by people that don't really understand what they are doing (the point of that link may not be immediately clear and it has nothing directly to do with the pi, but had me in ROTFL state the first time I saw it; also note there is a bit of foul language). This has a telephone game like effect on the internet and is characteristic of cargo cult programming. Do not fall down this rabbit hole, there is no rabbit, treasure, useful information, etc. of any sort inside.
Anyway...
How do you compile a c++ program to use Hard Float registers?
Presuming it's g++
, the current best practice invocation is probably:
g++ --std=c++11 -Wall -Wextra
Notice none of those have anything to do with the hard float ABI because if you are using the compiler than came with your arm-linux-gnueabihf
pi B+ distro, it will use the correct architecture settings anyway. Adding -march=armv6 -mfpu=vfp -mfloat-abi=hard
will be totally meaningless except to add extra wear to your -
m
, and =
keys. Sort of like ordering a cheeseburger by saying, "I'd like a cheeseburger with cheese and a beef patty in a bun".
If you are referring to a cross-compiler (you don't mention this in the question) you could use those, but if you got it from the official github tools or used a sane approach when building it, they'll be irrelevant there too.
Note that if you are using an armv7 cross compiler for the 2B (these are stock on most linux distros, unlike armv6 capable ones) you should leave out march-armv6
, it won't work, and armv7 binaries will work fine with Raspbian and other armv6 distros on a 2B.