diff mbox series

[5/7] simplify definition of __STRICT_ANSI__

Message ID 20191128204225.7002-6-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series add support for '-std=c17' | expand

Commit Message

Luc Van Oostenryck Nov. 28, 2019, 8:42 p.m. UTC
Currently, the definition of __STRICT_ANSI__ is done in the same
switch statement used for __STDC_VERSION__. However, this lead to
some repetions that can be avoided if moved outside of the switch.

Move the definition of __STRICT_ANSI__ out of the switch statement
and guard it by testing the absence of STANDARD_GNU.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 lib.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Ramsay Jones Dec. 1, 2019, 4:19 p.m. UTC | #1
On 28/11/2019 20:42, Luc Van Oostenryck wrote:
> Currently, the definition of __STRICT_ANSI__ is done in the same
> switch statement used for __STDC_VERSION__. However, this lead to
> some repetions that can be avoided if moved outside of the switch.
> 
> Move the definition of __STRICT_ANSI__ out of the switch statement
> and guard it by testing the absence of STANDARD_GNU.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  lib.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/lib.c b/lib.c
> index 02f6231e2..d232b8cee 100644
> --- a/lib.c
> +++ b/lib.c
> @@ -1408,24 +1408,16 @@ static void predefined_macros(void)
>  	default:
>  		break;
>  
> -	case STANDARD_C89:
> -		predefine("__STRICT_ANSI__", 1, "1");
> -	case STANDARD_GNU89:
> -		break;
> -
>  	case STANDARD_C94:
> -		predefine("__STRICT_ANSI__", 1, "1");
>  		predefine("__STDC_VERSION__", 1, "199409L");
>  		break;
>  
>  	case STANDARD_C99:
> -		predefine("__STRICT_ANSI__", 1, "1");
>  	case STANDARD_GNU99:
>  		predefine("__STDC_VERSION__", 1, "199901L");
>  		break;
>  
>  	case STANDARD_C11:
> -		predefine("__STRICT_ANSI__", 1, "1");
>  	case STANDARD_GNU11:
>  		predefine("__STDC_NO_ATOMICS__", 1, "1");
>  		predefine("__STDC_NO_COMPLEX__", 1, "1");
> @@ -1433,6 +1425,8 @@ static void predefined_macros(void)
>  		predefine("__STDC_VERSION__", 1, "201112L");
>  		break;
>  	}
> +	if (!(standard & STANDARD_GNU) & (standard != STANDARD_NONE))

s/) & (/) && (/

ATB,
Ramsay Jones

> +		predefine("__STRICT_ANSI__", 1, "1");
>  
>  	predefine("__CHAR_BIT__", 1, "%d", bits_in_char);
>  	if (funsigned_char)
>
Luc Van Oostenryck Dec. 1, 2019, 8:07 p.m. UTC | #2
On Sun, Dec 01, 2019 at 04:19:54PM +0000, Ramsay Jones wrote:
> On 28/11/2019 20:42, Luc Van Oostenryck wrote:
> > @@ -1433,6 +1425,8 @@ static void predefined_macros(void)
> >  		predefine("__STDC_VERSION__", 1, "201112L");
> >  		break;
> >  	}
> > +	if (!(standard & STANDARD_GNU) & (standard != STANDARD_NONE))
> 
> s/) & (/) && (/

Nice catch!
The result is the same, but it certainly wasn't my intention.

Thank you very much.
-- Luc
diff mbox series

Patch

diff --git a/lib.c b/lib.c
index 02f6231e2..d232b8cee 100644
--- a/lib.c
+++ b/lib.c
@@ -1408,24 +1408,16 @@  static void predefined_macros(void)
 	default:
 		break;
 
-	case STANDARD_C89:
-		predefine("__STRICT_ANSI__", 1, "1");
-	case STANDARD_GNU89:
-		break;
-
 	case STANDARD_C94:
-		predefine("__STRICT_ANSI__", 1, "1");
 		predefine("__STDC_VERSION__", 1, "199409L");
 		break;
 
 	case STANDARD_C99:
-		predefine("__STRICT_ANSI__", 1, "1");
 	case STANDARD_GNU99:
 		predefine("__STDC_VERSION__", 1, "199901L");
 		break;
 
 	case STANDARD_C11:
-		predefine("__STRICT_ANSI__", 1, "1");
 	case STANDARD_GNU11:
 		predefine("__STDC_NO_ATOMICS__", 1, "1");
 		predefine("__STDC_NO_COMPLEX__", 1, "1");
@@ -1433,6 +1425,8 @@  static void predefined_macros(void)
 		predefine("__STDC_VERSION__", 1, "201112L");
 		break;
 	}
+	if (!(standard & STANDARD_GNU) & (standard != STANDARD_NONE))
+		predefine("__STRICT_ANSI__", 1, "1");
 
 	predefine("__CHAR_BIT__", 1, "%d", bits_in_char);
 	if (funsigned_char)