simple #ifdef causes "error: function pointer expected"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

simple #ifdef causes "error: function pointer expected"

Massimo Sala
Hi

Compiling the attached sample, tcc bails out with "error: function pointer expected"
Pls, how can I fix ?
Best regards, Massimo

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
printf("ciao\n");
#if sizeof(size_t) == 64
printf("big boss\n");
#endif
return 0;
}


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: simple #ifdef causes "error: function pointer expected"

Aharon Robbins
This isn't valid C. The preprocessor doesn't know about sizeof.

Arnold

Massimo Sala <[hidden email]> wrote:

> Hi
>
> Compiling the attached sample, tcc bails out with "error: function pointer
> expected"
> Pls, how can I fix ?
> Best regards, Massimo
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> int main()
> {
> printf("ciao\n");
> #if sizeof(size_t) == 64
> printf("big boss\n");
> #endif
> return 0;
> }

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: simple #ifdef causes "error: function pointer expected"

Massimo Sala
Ops.

Pls any suggestion how to check with macro the sizeof size_t ?
Should I check the max value of a size_t to infer its size ?
I cannot find how to.

M

On Thu, 21 May 2020 at 14:08, <[hidden email]> wrote:
This isn't valid C. The preprocessor doesn't know about sizeof.

Arnold

Massimo Sala <[hidden email]> wrote:

> Hi
>
> Compiling the attached sample, tcc bails out with "error: function pointer
> expected"
> Pls, how can I fix ?
> Best regards, Massimo
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> int main()
> {
> printf("ciao\n");
> #if sizeof(size_t) == 64
> printf("big boss\n");
> #endif
> return 0;
> }

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: simple #ifdef causes "error: function pointer expected"

Christian Jullien-3

Hi,

In <stdint.h>, ISO C defines different macros that can help (you like UINTPTR_MAX).

Something like;

#if UINTPTR_MAX > UINT32_MAX

Is close to what you’re looking for.

 

C.

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Massimo Sala
Sent: Thursday, May 21, 2020 14:17
To: [hidden email]
Cc: [hidden email]
Subject: Re: [Tinycc-devel] simple #ifdef causes "error: function pointer expected"

 

Ops.

 

Pls any suggestion how to check with macro the sizeof size_t ?

Should I check the max value of a size_t to infer its size ?

I cannot find how to.

 

M

 

On Thu, 21 May 2020 at 14:08, <[hidden email]> wrote:

This isn't valid C. The preprocessor doesn't know about sizeof.

Arnold

Massimo Sala <[hidden email]> wrote:


> Hi
>
> Compiling the attached sample, tcc bails out with "error: function pointer
> expected"
> Pls, how can I fix ?
> Best regards, Massimo
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> int main()
> {
> printf("ciao\n");
> #if sizeof(size_t) == 64
> printf("big boss\n");
> #endif
> return 0;
> }

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: simple #ifdef causes "error: function pointer expected"

Massimo Sala
In reply to this post by Massimo Sala
I read about this topic.

Arnold wrote:
    This isn't valid C. The preprocessor doesn't know about sizeof.

I found this:
    C99 doesn't require support for "sizeof" in preprocessor conditionals and gcc for example doesn't support it.

Indeed this snippet compiles and run like a charm:

int main()
{
#define big sizeof(size_t)
printf("big boss %zd\n", big);
return 0;
}


Any suggestion how to check with macro the sizeof size_t ?
Should I check the max value of a size_t to infer its size ?

M


On Thu, 21 May 2020 at 14:17, Massimo Sala <[hidden email]> wrote:
Ops.

Pls any suggestion how to check with macro the sizeof size_t ?
Should I check the max value of a size_t to infer its size ?
I cannot find how to.

M

On Thu, 21 May 2020 at 14:08, <[hidden email]> wrote:
This isn't valid C. The preprocessor doesn't know about sizeof.

Arnold

Massimo Sala <[hidden email]> wrote:

> Hi
>
> Compiling the attached sample, tcc bails out with "error: function pointer
> expected"
> Pls, how can I fix ?
> Best regards, Massimo
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> int main()
> {
> printf("ciao\n");
> #if sizeof(size_t) == 64
> printf("big boss\n");
> #endif
> return 0;
> }

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: simple #ifdef causes "error: function pointer expected"

Christian Jullien-3
In reply to this post by Christian Jullien-3

Or maybe more readable:

 

#if (SIZE_MAX == UINT64_MAX)

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
Sent: Thursday, May 21, 2020 14:33
To: [hidden email]; [hidden email]
Subject: Re: [Tinycc-devel] simple #ifdef causes "error: function pointer expected"

 

Hi,

In <stdint.h>, ISO C defines different macros that can help (you like UINTPTR_MAX).

Something like;

#if UINTPTR_MAX > UINT32_MAX

Is close to what you’re looking for.

 

C.

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Massimo Sala
Sent: Thursday, May 21, 2020 14:17
To: [hidden email]
Cc: [hidden email]
Subject: Re: [Tinycc-devel] simple #ifdef causes "error: function pointer expected"

 

Ops.

 

Pls any suggestion how to check with macro the sizeof size_t ?

Should I check the max value of a size_t to infer its size ?

I cannot find how to.

 

M

 

On Thu, 21 May 2020 at 14:08, <[hidden email]> wrote:

This isn't valid C. The preprocessor doesn't know about sizeof.

Arnold

Massimo Sala <[hidden email]> wrote:


> Hi
>
> Compiling the attached sample, tcc bails out with "error: function pointer
> expected"
> Pls, how can I fix ?
> Best regards, Massimo
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> int main()
> {
> printf("ciao\n");
> #if sizeof(size_t) == 64
> printf("big boss\n");
> #endif
> return 0;
> }

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel