Fail to build SDL-2.0.5, after enabling -std=c99 ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fail to build SDL-2.0.5, after enabling -std=c99 ...

JIA Pei

Hi, all:


Working Environment: Ubuntu 16.04.2
GCC Version: 5.4.0


I successfully configured SDL-2.0.5 for further building. And I configured "-std=c99" for CMAKE_C_FLAGS, see the following:
CMAKE_C_FLAGS                    -std=c99


However, I get ERROR messages for the assembly code in file 
SDL_cpuinfo.c
SDL2-2.0.5/src/cpuinfo/SDL_cpuinfo.c:250:34: error: expected ‘)’ before ‘:’ token
    asm(".byte 0x0f, 0x01, 0xd0" : "=a" (a) : "c" (0) : "%edx");


I'm pretty sure this ERROR message has something to do with -std=c99 . I wonder which version of C is SDL2-2.0.5 compatible with?


Cheers


--

Pei JIA, Ph.D.

cell in Canada:    +1 778-863-5816
cell in China: +86 186-8244-3503

Welcome to Vision Open
http://www.visionopen.com

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fail to build SDL-2.0.5, after enabling -std=c99 ...

Sik the hedgehog
Try -std=gnu99 (if I recall correctly)

Looks like the problem is using asm instead of a reserved keyword
(whoops). -std=c99 will disable any extensions, -std=gnu99 will keep
them.
_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fail to build SDL-2.0.5, after enabling -std=c99 ...

JIA Pei

Thank you... That works for me.... Thanks...

On Fri, Mar 3, 2017 at 2:13 PM, Sik the hedgehog <[hidden email]> wrote:
Try -std=gnu99 (if I recall correctly)

Looks like the problem is using asm instead of a reserved keyword
(whoops). -std=c99 will disable any extensions, -std=gnu99 will keep
them.
_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



--

Pei JIA, Ph.D.

cell in Canada:    +1 778-863-5816
cell in China: +86 186-8244-3503

Welcome to Vision Open
http://www.visionopen.com

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fail to build SDL-2.0.5, after enabling -std=c99 ...

Ryan C. Gordon
In reply to this post by Sik the hedgehog
On 3/3/17 5:13 PM, Sik the hedgehog wrote:
> Try -std=gnu99 (if I recall correctly)
>
> Looks like the problem is using asm instead of a reserved keyword
> (whoops). -std=c99 will disable any extensions, -std=gnu99 will keep
> them.

So the actual fix should be to change that to __asm__, right?

--ryan.



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fail to build SDL-2.0.5, after enabling -std=c99 ...

JIA Pei

Hi, Ryan:


My current solution is to change -std=c99 to -std=gnu99.

I'm testing your solution, which seems to be correct !!! However, I'm NOW facing some new issues:

SDL2/SDL2-2.0.5/src/render/software/SDL_rotate.c:136:29: error: M_PI’ undeclared (first use in this function)
        radangle = angle * (M_PI / -180.0); /* reverse the angle because our rotations are clockwise */

SDL2/SDL2-2.0.5/src/events/SDL_quit.c:55:22: error: storage size of ‘action’ isn’t known
    struct sigaction action;


I can easily solve the first problem  'M_PI' hasn't been declared by defining M_PI as:
#ifndef M_PI
#define M_PI    3.14159265358979323846264338327950288   /* pi */
#endif


However, how to solve the second issue ????
SDL2/SDL2-2.0.5/src/events/SDL_quit.c:55:22: error: storage size of ‘action’ isn’t known 
    struct sigaction action;


Cheers


On Mon, Mar 6, 2017 at 2:00 PM, Ryan C. Gordon <[hidden email]> wrote:
On 3/3/17 5:13 PM, Sik the hedgehog wrote:
Try -std=gnu99 (if I recall correctly)

Looks like the problem is using asm instead of a reserved keyword
(whoops). -std=c99 will disable any extensions, -std=gnu99 will keep
them.

So the actual fix should be to change that to __asm__, right?

--ryan.




_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



--

Pei JIA, Ph.D.

cell in Canada:    +1 778-863-5816
cell in China: +86 186-8244-3503

Welcome to Vision Open
http://www.visionopen.com

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fail to build SDL-2.0.5, after enabling -std=c99 ...

Daniel Gibson
Hi,

building with -std=c99 (instead of gnu99) doesn't only change the syntax
that's accepted by the compiler, but also what parts of headers are used.
All (or most?) things in standard headers that are not part of the C99
standard, like "GNU extensions" is not enabled (this is the "#define
_GNU_SOURCE" stuff mentioned in manpages).
IMHO it's not very useful to use -std=c99, especially for code like
libSDL that needs to do operating-system specific things. Just use
-std=gnu99 (or even gnu89)..


Cheers,
Daniel

On 07.03.2017 02:01, JIA Pei wrote:

>
> Hi, Ryan:
>
>
> My current solution is to*change -std=c99 to -std=gnu99.*
>
> I'm testing your solution, which seems to be correct !!! However, I'm
> NOW facing some new issues:
>
> SDL2/SDL2-2.0.5/src/render/software/SDL_rotate.c:136:29:error: ‘M_PI’
> undeclared (first use in this function)
>         radangle = angle * (M_PI / -180.0); /* reverse the angle because
> our rotations are clockwise */
>
> SDL2/SDL2-2.0.5/src/events/SDL_quit.c:55:22:error: storage size of
> ‘action’ isn’t known
>     struct sigaction action;
>
>
> I can easily solve the first problem  *'M_PI' hasn't been declared* by
> defining *M_PI *as*:*
>
>     *#ifndef M_PI*
>     *#define M_PI    3.14159265358979323846264338327950288   /* pi */*
>     *#endif*
>
>
>
> However, how to solve the second issue ????
> SDL2/SDL2-2.0.5/src/events/SDL_quit.c:55:22: error: storage size of
> ‘action’ isn’t known
>     struct sigaction action;
>
>
> Cheers
>
>
> On Mon, Mar 6, 2017 at 2:00 PM, Ryan C. Gordon <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     On 3/3/17 5:13 PM, Sik the hedgehog wrote:
>
>         Try -std=gnu99 (if I recall correctly)
>
>         Looks like the problem is using asm instead of a reserved keyword
>         (whoops). -std=c99 will disable any extensions, -std=gnu99 will keep
>         them.
>
>
>     So the actual fix should be to change that to __asm__, right?
>
>     --ryan.
>
>
>
>
>     _______________________________________________
>     SDL mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>     <http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>
>
>
>
>
> --
>
> Pei JIA, Ph.D.
>
> Email: [hidden email] <mailto:[hidden email]>
> cell in Canada:    +1 778-863-5816
> cell in China: +86 186-8244-3503
>
> Welcome to Vision Open
> http://www.visionopen.com
>
>
> _______________________________________________
> SDL mailing list
> [hidden email]
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fail to build SDL-2.0.5, after enabling -std=c99 ...

JIA Pei
Thank you Daniel... Thank you for your very clear explanation...

Cheers

On Mon, Mar 6, 2017 at 5:09 PM, Daniel Gibson <[hidden email]> wrote:
Hi,

building with -std=c99 (instead of gnu99) doesn't only change the syntax that's accepted by the compiler, but also what parts of headers are used.
All (or most?) things in standard headers that are not part of the C99 standard, like "GNU extensions" is not enabled (this is the "#define _GNU_SOURCE" stuff mentioned in manpages).
IMHO it's not very useful to use -std=c99, especially for code like libSDL that needs to do operating-system specific things. Just use -std=gnu99 (or even gnu89)..


Cheers,
Daniel

On 07.03.2017 02:01, JIA Pei wrote:

Hi, Ryan:


My current solution is to*change -std=c99 to -std=gnu99.*

I'm testing your solution, which seems to be correct !!! However, I'm
NOW facing some new issues:

SDL2/SDL2-2.0.5/src/render/software/SDL_rotate.c:136:29:error: ‘M_PI’
undeclared (first use in this function)
        radangle = angle * (M_PI / -180.0); /* reverse the angle because
our rotations are clockwise */

SDL2/SDL2-2.0.5/src/events/SDL_quit.c:55:22:error: storage size of
‘action’ isn’t known
    struct sigaction action;


I can easily solve the first problem  *'M_PI' hasn't been declared* by
defining *M_PI *as*:*

    *#ifndef M_PI*
    *#define M_PI    3.14159265358979323846264338327950288   /* pi */*
    *#endif*



However, how to solve the second issue ????
SDL2/SDL2-2.0.5/src/events/SDL_quit.c:55:22: error: storage size of
‘action’ isn’t known
    struct sigaction action;


Cheers


On Mon, Mar 6, 2017 at 2:00 PM, Ryan C. Gordon <[hidden email]
<mailto:[hidden email]>> wrote:

    On 3/3/17 5:13 PM, Sik the hedgehog wrote:

        Try -std=gnu99 (if I recall correctly)

        Looks like the problem is using asm instead of a reserved keyword
        (whoops). -std=c99 will disable any extensions, -std=gnu99 will keep
        them.


    So the actual fix should be to change that to __asm__, right?

    --ryan.




    _______________________________________________
    SDL mailing list
    [hidden email] <mailto:[hidden email]>
    http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
    <http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>




--

Pei JIA, Ph.D.

Email: [hidden email] <mailto:[hidden email]>
cell in Canada:    <a href="tel:%2B1%20778-863-5816" value="+17788635816" target="_blank">+1 778-863-5816
cell in China: <a href="tel:%2B86%20186-8244-3503" value="+8618682443503" target="_blank">+86 186-8244-3503

Welcome to Vision Open
http://www.visionopen.com


_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



--

Pei JIA, Ph.D.

cell in Canada:    +1 778-863-5816
cell in China: +86 186-8244-3503

Welcome to Vision Open
http://www.visionopen.com

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Loading...