public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum
@ 2024-03-07 14:11 Homam Alkhateeb
  2024-03-07 14:20 ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Homam Alkhateeb @ 2024-03-07 14:11 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1429 bytes --]

Hello GCC-Support Team,

we're using the gcc compiler version 4.7.0 and dialect -std=c99 with Option -fshort-enums to compile a C project on a Host Simulation using TESSY.
according to the Using the GNU Compiler Collection<https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc.pdf> Page 302: if there are negative values it is the first of signed char, short and int that can represent all the values, otherwise it is the first of unsigned char, unsigned short and unsigned int that can represent all the values.

On the Real Target we use the GHS_PPC_Compiler_2022_1_4 C99 with the --short_enum option. We want to make short enums identical for both Compiler.
according to the PPC ABI, enum members are signed. The --short_enum option instructs the compiler to use the smallest possible data type:
First short, then unsigned short, then signed int, then unsigned int etc.

e.g.

typedef enum
{
    MY_ENUM_A = 0,
    MY_ENUM_A = 256
} MY_ENUM;

MY_ENUM Value;  /* Value is here short using GHS_PPC_Compiler_2022_1_4 C99 with the --short_enum
                                       but unsigned short using GNU with the -fshort_enums */

Mit freundlichen Grüßen / Best regards
Homam Alkhateeb
KOPF GmbH / Kapbachstr. 6 / 76829 Landau / Germany
Tel.: +49 6341 91767-36 / Email: homam.alkhateeb@kopfweb.de
<mailto:homam.alkhateeb@kopfweb.de>Geschäftsführer: Oliver Kopf - HRB Landau Nr. 3090 - Amtsgericht Landau


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum
  2024-03-07 14:11 Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum Homam Alkhateeb
@ 2024-03-07 14:20 ` Jonathan Wakely
  2024-03-08  7:36   ` AW: " Homam Alkhateeb
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2024-03-07 14:20 UTC (permalink / raw)
  To: Homam Alkhateeb; +Cc: gcc-help

On Thu, 7 Mar 2024 at 14:11, Homam Alkhateeb <Homam.Alkhateeb@kopfweb.de> wrote:
>
> Hello GCC-Support Team,
>
> we're using the gcc compiler version 4.7.0 and dialect -std=c99 with Option -fshort-enums to compile a C project on a Host Simulation using TESSY.
> according to the Using the GNU Compiler Collection<https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc.pdf> Page 302: if there are negative values it is the first of signed char, short and int that can represent all the values, otherwise it is the first of unsigned char, unsigned short and unsigned int that can represent all the values.
>
> On the Real Target we use the GHS_PPC_Compiler_2022_1_4 C99 with the --short_enum option. We want to make short enums identical for both Compiler.
> according to the PPC ABI, enum members are signed. The --short_enum option instructs the compiler to use the smallest possible data type:
> First short, then unsigned short, then signed int, then unsigned int etc.
>
> e.g.
>
> typedef enum
> {
>     MY_ENUM_A = 0,
>     MY_ENUM_A = 256

Add a negative value, MY_ENUM_NEG = -1

Now GCC will use short instead of unsigned short.

> } MY_ENUM;
>
> MY_ENUM Value;  /* Value is here short using GHS_PPC_Compiler_2022_1_4 C99 with the --short_enum
>                                        but unsigned short using GNU with the -fshort_enums */
>
> Mit freundlichen Grüßen / Best regards
> Homam Alkhateeb
> KOPF GmbH / Kapbachstr. 6 / 76829 Landau / Germany
> Tel.: +49 6341 91767-36 / Email: homam.alkhateeb@kopfweb.de
> <mailto:homam.alkhateeb@kopfweb.de>Geschäftsführer: Oliver Kopf - HRB Landau Nr. 3090 - Amtsgericht Landau
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* AW: Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum
  2024-03-07 14:20 ` Jonathan Wakely
@ 2024-03-08  7:36   ` Homam Alkhateeb
  2024-03-08 14:11     ` Segher Boessenkool
  0 siblings, 1 reply; 5+ messages in thread
From: Homam Alkhateeb @ 2024-03-08  7:36 UTC (permalink / raw)
  To: gcc-help; +Cc: Jonathan Wakely

Is there a way to do this without changing the code?

Mit freundlichen Grüßen / Best regards
Homam Alkhateeb
KOPF GmbH / Kapbachstr. 6 / 76829 Landau / Germany
Tel.: +49 6341 91767-36 / Email: homam.alkhateeb@kopfweb.de
Geschäftsführer: Oliver Kopf - HRB Landau Nr. 3090 - Amtsgericht Landau 

-----Ursprüngliche Nachricht-----
Von: Jonathan Wakely <jwakely.gcc@gmail.com> 
Gesendet: Donnerstag, 7. März 2024 15:20
An: Homam Alkhateeb <Homam.Alkhateeb@kopfweb.de>
Cc: gcc-help@gcc.gnu.org
Betreff: Re: Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum

On Thu, 7 Mar 2024 at 14:11, Homam Alkhateeb <Homam.Alkhateeb@kopfweb.de> wrote:
>
> Hello GCC-Support Team,
>
> we're using the gcc compiler version 4.7.0 and dialect -std=c99 with Option -fshort-enums to compile a C project on a Host Simulation using TESSY.
> according to the Using the GNU Compiler Collection<https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc.pdf> Page 302: if there are negative values it is the first of signed char, short and int that can represent all the values, otherwise it is the first of unsigned char, unsigned short and unsigned int that can represent all the values.
>
> On the Real Target we use the GHS_PPC_Compiler_2022_1_4 C99 with the --short_enum option. We want to make short enums identical for both Compiler.
> according to the PPC ABI, enum members are signed. The --short_enum option instructs the compiler to use the smallest possible data type:
> First short, then unsigned short, then signed int, then unsigned int etc.
>
> e.g.
>
> typedef enum
> {
>     MY_ENUM_A = 0,
>     MY_ENUM_A = 256

Add a negative value, MY_ENUM_NEG = -1

Now GCC will use short instead of unsigned short.

> } MY_ENUM;
>
> MY_ENUM Value;  /* Value is here short using GHS_PPC_Compiler_2022_1_4 C99 with the --short_enum
>                                        but unsigned short using GNU 
> with the -fshort_enums */
>
> Mit freundlichen Grüßen / Best regards Homam Alkhateeb KOPF GmbH / 
> Kapbachstr. 6 / 76829 Landau / Germany
> Tel.: +49 6341 91767-36 / Email: homam.alkhateeb@kopfweb.de
> <mailto:homam.alkhateeb@kopfweb.de>Geschäftsführer: Oliver Kopf - HRB 
> Landau Nr. 3090 - Amtsgericht Landau
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum
  2024-03-08  7:36   ` AW: " Homam Alkhateeb
@ 2024-03-08 14:11     ` Segher Boessenkool
  2024-03-08 14:24       ` AW: " Homam Alkhateeb
  0 siblings, 1 reply; 5+ messages in thread
From: Segher Boessenkool @ 2024-03-08 14:11 UTC (permalink / raw)
  To: Homam Alkhateeb; +Cc: gcc-help

On Fri, Mar 08, 2024 at 07:36:17AM +0000, Homam Alkhateeb wrote:
> Is there a way to do this without changing the code?

No.  Your system ABI requires what underlying type to use for an enum.
There would be terrible problems if a compiler could just choose to use
different types willy-nilly!


Segher

^ permalink raw reply	[flat|nested] 5+ messages in thread

* AW: Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum
  2024-03-08 14:11     ` Segher Boessenkool
@ 2024-03-08 14:24       ` Homam Alkhateeb
  0 siblings, 0 replies; 5+ messages in thread
From: Homam Alkhateeb @ 2024-03-08 14:24 UTC (permalink / raw)
  To: gcc-help; +Cc: Segher Boessenkool

understood! Many thanks for your help

Mit freundlichen Grüßen / Best regards
Homam Alkhateeb
KOPF GmbH / Kapbachstr. 6 / 76829 Landau / Germany
Tel.: +49 6341 91767-36 / Email: homam.alkhateeb@kopfweb.de
Geschäftsführer: Oliver Kopf - HRB Landau Nr. 3090 - Amtsgericht Landau 

-----Ursprüngliche Nachricht-----
Von: Segher Boessenkool <segher@kernel.crashing.org> 
Gesendet: Freitag, 8. März 2024 15:11
An: Homam Alkhateeb <Homam.Alkhateeb@kopfweb.de>
Cc: gcc-help@gcc.gnu.org
Betreff: Re: Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum

On Fri, Mar 08, 2024 at 07:36:17AM +0000, Homam Alkhateeb wrote:
> Is there a way to do this without changing the code?

No.  Your system ABI requires what underlying type to use for an enum.
There would be terrible problems if a compiler could just choose to use different types willy-nilly!


Segher

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-08 14:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-07 14:11 Gnu compiler version 4.7.0, dialect -std=c99 with -fshort-enums vs. GHS with --short_enum Homam Alkhateeb
2024-03-07 14:20 ` Jonathan Wakely
2024-03-08  7:36   ` AW: " Homam Alkhateeb
2024-03-08 14:11     ` Segher Boessenkool
2024-03-08 14:24       ` AW: " Homam Alkhateeb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).