JGPIO
Posts: 25
Joined: Sun Feb 28, 2016 6:29 pm

RPi3 macros

Thu Aug 25, 2016 10:54 am

I've just received an RPi3 and I'm a little surprised that __ARM_ARCH_6__ is defined rather than __ARM_ARCH_7__

Have I misunderstood something or is this wrong?

Many thanks.

jahboater
Posts: 5950
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: RPi3 macros

Thu Aug 25, 2016 11:08 am

It should actually be __ARM_ARCH_8A__ for the cortex-a53.
But remember the Rasbian distribution is backwards compatible all the way to the PiZero which is V6.
You can build your own compiler of course (gcc 6.2 is the latest).

JGPIO
Posts: 25
Joined: Sun Feb 28, 2016 6:29 pm

Re: RPi3 macros

Thu Aug 25, 2016 11:10 am

Well yes, I was actually expecting __ARM_ARCH_8__ to be defined.

jahboater
Posts: 5950
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: RPi3 macros

Thu Aug 25, 2016 11:56 am

If you give the correct options for the Pi3 CPU (which are: -mcpu=cortex-a53 -mfpu=neon-fp-armv8 ) you will have __ARM_ARCH_8A__ defined, even with the old compiler.

JGPIO
Posts: 25
Joined: Sun Feb 28, 2016 6:29 pm

Re: RPi3 macros

Thu Aug 25, 2016 12:33 pm

jahboater wrote:If you give the correct options for the Pi3 CPU (which are: -mcpu=cortex-a53 -mfpu=neon-fp-armv8 ) you will have __ARM_ARCH_8A__ defined, even with the old compiler.
Nice! I just tried it. Thank you very much for that.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26868
Joined: Sat Jul 30, 2011 7:41 pm

Re: RPi3 macros

Thu Aug 25, 2016 1:37 pm

JGPIO wrote:Well yes, I was actually expecting __ARM_ARCH_8__ to be defined.
Compiler defaults to lowest common denominator - the Pi1/0. You need to manually set it higher if targeting specifically the Pi3. As mentioned above.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

JGPIO
Posts: 25
Joined: Sun Feb 28, 2016 6:29 pm

Re: RPi3 macros

Thu Aug 25, 2016 2:50 pm

Thank you all for your help.

I haven't used gcc since my SCO Unix days in the second half of the 1990's.

Much re-learning to do!

Return to “C/C++”