compile issues under mingw-cross-env
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak: 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't). 2) I had to remove the definition of _POSIX_C_SOURCE=200112 because defining it causes pid_t to not be defined in sched.h. I used the following command line to configure: $ configure --enable-postproc --enable-gpl --enable-x11grab --enable-pthreads --enable-nonfree --enable-libvorbis --target-os=mingw32 --enable-memalign-hack --arch=x86_64 --cross-prefix=i686-pc-mingw32- Note this is a 64-bit windows build (arch=x86_64). After making these changes in the generated config.mak file, ffmpeg and utilities compiled - not cleanly, mind you, but at least as cleanly as it does in normal non-cross builds. Any comments would be appreciated. Perhaps I'm doing something fundamentally wrong in my cross compile? Thanks in advance, John
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
2) I had to remove the definition of _POSIX_C_SOURCE=200112 because defining it causes pid_t to not be defined in sched.h.
Wrong again. We do not use sched.h at all. We include sys/wait.h, which defers to sys/types.h for the pid_t type. The standard requires that sys/types.h define pid_t with no extra conditions imposed.
I used the following command line to configure:
$ configure --enable-postproc --enable-gpl --enable-x11grab --enable-pthreads --enable-nonfree --enable-libvorbis --target-os=mingw32 --enable-memalign-hack --arch=x86_64 --cross-prefix=i686-pc-mingw32-
Note this is a 64-bit windows build (arch=x86_64).
The combination of 64-bit and mingw is likely a recipe for trouble. Maybe the cross-tools are better than regular mingw, I don't know.
After making these changes in the generated config.mak file, ffmpeg and utilities compiled - not cleanly, mind you, but at least as cleanly as it does in normal non-cross builds.
What is that supposed to mean? Condescending remarks like that will not win our hearts.
Any comments would be appreciated. Perhaps I'm doing something fundamentally wrong in my cross compile?
You seem to be using a non-c99 compilation environment. This is not particularly well supported. -- M?ns Rullg?rd mans at mansr.com
M?ns, On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
2) I had to remove the definition of _POSIX_C_SOURCE=200112 because defining it causes pid_t to not be defined in sched.h.
Wrong again. We do not use sched.h at all. We include sys/wait.h, which defers to sys/types.h for the pid_t type. The standard requires that sys/types.h define pid_t with no extra conditions imposed.
$ make V=1 i686-pc-mingw32-gcc -I. -I"/home/jcalcote/dev/svn/ffmpeg-trunk/svn" -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DHAVE_AV_CONFIG_H -std=gnu99 -fno-common -fomit-frame-pointer -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -Werror=missing-prototypes -MMD -MF libavcodec/pthread.d -MT libavcodec/pthread.o -c -o libavcodec/pthread.o /home/jcalcote/dev/svn/ffmpeg-trunk/svn/libavcodec/pthread.c In file included from /opt/mingw-cross-env-2.15/usr/bin/../lib/gcc/i686-pc-mingw32/4.5.0/../../../../i686-pc-mingw32/include/pthread.h:289:0, from /home/jcalcote/dev/svn/ffmpeg-trunk/svn/libavcodec/pthread.c:24: /opt/mingw-cross-env-2.15/usr/bin/../lib/gcc/i686-pc-mingw32/4.5.0/../../../../i686-pc-mingw32/include/sched.h:153:53: error: expected ')' before 'pid' /opt/mingw-cross-env-2.15/usr/bin/../lib/gcc/i686-pc-mingw32/4.5.0/../../../../i686-pc-mingw32/include/sched.h:155:53: error: expected ')' before 'pid' make: *** [libavcodec/pthread.o] Error 1 You're probably unaware of how pid_t is defined through sched.h via mingw's pthread.h file. I'm not trying to tell you you're wrong - I'm sure this is a very platform (mingw) specific thing.
I used the following command line to configure:
$ configure --enable-postproc --enable-gpl --enable-x11grab --enable-pthreads --enable-nonfree --enable-libvorbis --target-os=mingw32 --enable-memalign-hack --arch=x86_64 --cross-prefix=i686-pc-mingw32-
Note this is a 64-bit windows build (arch=x86_64).
The combination of 64-bit and mingw is likely a recipe for trouble. Maybe the cross-tools are better than regular mingw, I don't know.
What I like about cross-env is that it's actually being maintained regularly. I've tried various other platforms and tool sets, but I've not been able to find anything that works as well as this project.
After making these changes in the generated config.mak file, ffmpeg and utilities compiled - not cleanly, mind you, but at least as cleanly as it does in normal non-cross builds.
What is that supposed to mean? Condescending remarks like that will not win our hearts.
I'm sorry. I really didn't mean to sound condescending. I can see how it came across that way. I was simply trying to say that there aren't any more warnings than there normally are. Please accept my apologies. Thanks for the comments, John
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. ?strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. ?strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect. -Eli
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors. To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms. Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001). John
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2]. So in this case it's mingw that's wrong. [1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
David Conrad <lessen42 at gmail.com> writes:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
> Anyone ever tried compiling ffmpeg under mingw-cross-env > (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and > I've found the following issues with CPPFLAGS in the generated config.mak: > > 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is > enabled if -std=c99 is used which means functions like strcasecmp aren't > available (at least the prototypes aren't). > > Wrong. strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
This is inaccurate. In the gcc manual, the description of the -std= flag mentions only _language_ extensions (additional keywords etc.), nothing about library support. GCC is, after all, a compiler, not a C library.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
That is in stark contradiction to what the POSIX spec says. The description of the _POSIX_C_SOURCE macro makes no exceptions.
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
Small correction, _XOPEN_SOURCE must be set to 600 as well. strcasecmp() is part of the XSI extensions.
So in this case it's mingw that's wrong.
It could be argued that mingw isn't attempting to be POSIX-compliant at all, and hence is not "wrong" per se. It would, however, be reasonable of them to follow the spec for the subset they do provide.
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
-- M?ns Rullg?rd mans at mansr.com
On 7/11/2010 3:40 AM, M?ns Rullg?rd wrote:
David Conrad <lessen42 at gmail.com> writes:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
> John Calcote <john.calcote at gmail.com> writes: > > >> Anyone ever tried compiling ffmpeg under mingw-cross-env >> (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and >> I've found the following issues with CPPFLAGS in the generated config.mak: >> >> 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is >> enabled if -std=c99 is used which means functions like strcasecmp aren't >> available (at least the prototypes aren't). >> >> >> > Wrong. strcasecmp() is part of C99 and on any conforming system is > declared when using those flags. > > > I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
This is inaccurate. In the gcc manual, the description of the -std= flag mentions only _language_ extensions (additional keywords etc.), nothing about library support. GCC is, after all, a compiler, not a C library.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
That is in stark contradiction to what the POSIX spec says. The description of the _POSIX_C_SOURCE macro makes no exceptions.
What could the POSIX spec possibly have to say about anything outside of the scope of the POSIX spec? For example, let's say, for the sake of argument, that you're using a compiler that supports a hypothetical switch, --disable-all-extension-macros, which does what its name implies. If you use this switch in conjunction with _POSIX_C_SOURCE, how would you expect the POSIX spec to discuss interaction with such a switch? Frankly, it's not reasonable to assume the POSIX spec would have _anything_ to say about it. Thus, what would POSIX have to say about the use of a --std=c99 switch.
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
Small correction, _XOPEN_SOURCE must be set to 600 as well. strcasecmp() is part of the XSI extensions.
So in this case it's mingw that's wrong.
It could be argued that mingw isn't attempting to be POSIX-compliant at all, and hence is not "wrong" per se. It would, however, be reasonable of them to follow the spec for the subset they do provide.
For the record, I believe mingw is doing something odd. The entire goal of their project is to provide a Windows portability mechanism for Unix source code. It seems silly to not support something widely done in the Unix world. John
On 7/10/2010 11:11 PM, David Conrad wrote:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
> Anyone ever tried compiling ffmpeg under mingw-cross-env > (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and > I've found the following issues with CPPFLAGS in the generated config.mak: > > 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is > enabled if -std=c99 is used which means functions like strcasecmp aren't > available (at least the prototypes aren't). > > > Wrong. strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
So in this case it's mingw that's wrong.
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
David, your statement is 100 percent true but you missed my point entirely. Basically, -std=c99 and _POSIX_C_SOURCE=200112L are conflicting flags that, when used together, give undefined results. It's cool that the results you've gotten so far are what you wanted, but you can't count on those results on all platforms because the results of using the two together is not defined by any standard. I'm suggesting that what the ffmpeg community really wants to use is the POSIX flag, and that using the c99 flag in conjunction with it is problematic. John
On Sun, Jul 11, 2010 at 1:33 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 11:11 PM, David Conrad wrote:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
> John Calcote <john.calcote at gmail.com> writes: > > >> Anyone ever tried compiling ffmpeg under mingw-cross-env >> (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and >> I've found the following issues with CPPFLAGS in the generated config.mak: >> >> 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is >> enabled if -std=c99 is used which means functions like strcasecmp aren't >> available (at least the prototypes aren't). >> >> >> > Wrong. ?strcasecmp() is part of C99 and on any conforming system is > declared when using those flags. > > > I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. ?So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
So in this case it's mingw that's wrong.
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
David, your statement is 100 percent true but you missed my point entirely. Basically, -std=c99 and _POSIX_C_SOURCE=200112L are conflicting flags that, when used together, give undefined results. It's cool that the results you've gotten so far are what you wanted, but you can't count on those results on all platforms because the results of using the two together is not defined by any standard.
The conflict in question doesn't exist. _POSIX_C_SOURCE is a reserved identifier in C99, so defining it means that POSIX can override anything the C99 standard says. -Eli
On 7/11/2010 2:52 PM, Eli Friedman wrote:
On Sun, Jul 11, 2010 at 1:33 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 11:11 PM, David Conrad wrote:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
> On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote: > > > >> John Calcote <john.calcote at gmail.com> writes: >> >> >> >>> Anyone ever tried compiling ffmpeg under mingw-cross-env >>> (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and >>> I've found the following issues with CPPFLAGS in the generated config.mak: >>> >>> 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is >>> enabled if -std=c99 is used which means functions like strcasecmp aren't >>> available (at least the prototypes aren't). >>> >>> >>> >>> >> Wrong. strcasecmp() is part of C99 and on any conforming system is >> declared when using those flags. >> >> >> >> > I'm not seeing strcasecmp as being part of C99. I'm seeing it as being > part of POSIX 2001... Are you sure you're correct on this one? When I > google search strcasecmp and c99, I get very little information on the > pair. However, most of what I do get appear to be comments about how > ffmpeg doesn't compile under mingw. > > > 'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
So in this case it's mingw that's wrong.
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
David, your statement is 100 percent true but you missed my point entirely. Basically, -std=c99 and _POSIX_C_SOURCE=200112L are conflicting flags that, when used together, give undefined results. It's cool that the results you've gotten so far are what you wanted, but you can't count on those results on all platforms because the results of using the two together is not defined by any standard.
The conflict in question doesn't exist. _POSIX_C_SOURCE is a reserved identifier in C99, so defining it means that POSIX can override anything the C99 standard says.
Eli, what is the basis of your remarks? 1) I've searched the current publically available C99 standard (WG14 N1256 [C99 + TC1 + TC2 + TC3] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf, referenced from http://www.open-std.org/jtc1/sc22/wg14/www/standards) and I see no references to _POSIX_C_SOURCE, either as a reserved identifier, or otherwise. In fact the only reference to POSIX at all is found in the Bibliography [entry 16] and refers only to Part II: Shell and Utilities. If C99 had anything to say about POSIX as a standard, I would expect to find a reference to it in section 2 Normative References, or at least in the Appendices as informative references. 2) Even if _POSIX_C_SOURCE was a reserved identifier (which you can see from my first point is not true at all), it still would not follow that POSIX can override anything the C99 standard says. Regards, John
On Sun, Jul 11, 2010 at 2:34 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/11/2010 2:52 PM, Eli Friedman wrote:
On Sun, Jul 11, 2010 at 1:33 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 11:11 PM, David Conrad wrote:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
> On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote: > > > >> On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote: >> >> >> >>> John Calcote <john.calcote at gmail.com> writes: >>> >>> >>> >>>> Anyone ever tried compiling ffmpeg under mingw-cross-env >>>> (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and >>>> I've found the following issues with CPPFLAGS in the generated config.mak: >>>> >>>> 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is >>>> enabled if -std=c99 is used which means functions like strcasecmp aren't >>>> available (at least the prototypes aren't). >>>> >>>> >>>> >>>> >>> Wrong. ?strcasecmp() is part of C99 and on any conforming system is >>> declared when using those flags. >>> >>> >>> >>> >> I'm not seeing strcasecmp as being part of C99. I'm seeing it as being >> part of POSIX 2001... Are you sure you're correct on this one? When I >> google search strcasecmp and c99, I get very little information on the >> pair. However, most of what I do get appear to be comments about how >> ffmpeg doesn't compile under mingw. >> >> >> > 'man standards' says: > "POSIX.1-2001 is aligned with C99, so that all of the library > functions standardised in C99 are also standardised in POSIX.1-1001." > > > strcasecmp is defined in strings.h, which is not part of C99. ?So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
So in this case it's mingw that's wrong.
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
David, your statement is 100 percent true but you missed my point entirely. Basically, -std=c99 and _POSIX_C_SOURCE=200112L are conflicting flags that, when used together, give undefined results. It's cool that the results you've gotten so far are what you wanted, but you can't count on those results on all platforms because the results of using the two together is not defined by any standard.
The conflict in question doesn't exist. ?_POSIX_C_SOURCE is a reserved identifier in C99, so defining it means that POSIX can override anything the C99 standard says.
Eli, what is the basis of your remarks?
1) I've searched the current publically available C99 standard (WG14 N1256 [C99 + TC1 + TC2 + TC3] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf, referenced from http://www.open-std.org/jtc1/sc22/wg14/www/standards) and I see no references to _POSIX_C_SOURCE, either as a reserved identifier, or otherwise. In fact the only reference to POSIX at all is found in the Bibliography [entry 16] and refers only to Part II: Shell and Utilities. If C99 had anything to say about POSIX as a standard, I would expect to find a reference to it in section 2 Normative References, or at least in the Appendices as informative references.
C99 7.1.3p1 "All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use."
2) Even if _POSIX_C_SOURCE was a reserved identifier (which you can see from my first point is not true at all), it still would not follow that POSIX can override anything the C99 standard says.
C99 7.1.3p2 "If the program [,,,] defines a reserved identifier as a macro name, the behavior is undefined. -Eli
On 7/11/2010 3:40 PM, Eli Friedman wrote:
On Sun, Jul 11, 2010 at 2:34 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/11/2010 2:52 PM, Eli Friedman wrote:
On Sun, Jul 11, 2010 at 1:33 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 11:11 PM, David Conrad wrote:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
> On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote: > > > > >> On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote: >> >> >> >> >>> On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote: >>> >>> >>> >>> >>>> John Calcote <john.calcote at gmail.com> writes: >>>> >>>> >>>> >>>> >>>>> Anyone ever tried compiling ffmpeg under mingw-cross-env >>>>> (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and >>>>> I've found the following issues with CPPFLAGS in the generated config.mak: >>>>> >>>>> 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is >>>>> enabled if -std=c99 is used which means functions like strcasecmp aren't >>>>> available (at least the prototypes aren't). >>>>> >>>>> >>>>> >>>>> >>>>> >>>> Wrong. strcasecmp() is part of C99 and on any conforming system is >>>> declared when using those flags. >>>> >>>> >>>> >>>> >>>> >>> I'm not seeing strcasecmp as being part of C99. I'm seeing it as being >>> part of POSIX 2001... Are you sure you're correct on this one? When I >>> google search strcasecmp and c99, I get very little information on the >>> pair. However, most of what I do get appear to be comments about how >>> ffmpeg doesn't compile under mingw. >>> >>> >>> >>> >> 'man standards' says: >> "POSIX.1-2001 is aligned with C99, so that all of the library >> functions standardised in C99 are also standardised in POSIX.1-1001." >> >> >> >> > strcasecmp is defined in strings.h, which is not part of C99. So > -std=c99 vs. -std=gnu99 shouldn't have any affect. > > > > I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
So in this case it's mingw that's wrong.
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
David, your statement is 100 percent true but you missed my point entirely. Basically, -std=c99 and _POSIX_C_SOURCE=200112L are conflicting flags that, when used together, give undefined results. It's cool that the results you've gotten so far are what you wanted, but you can't count on those results on all platforms because the results of using the two together is not defined by any standard.
The conflict in question doesn't exist. _POSIX_C_SOURCE is a reserved identifier in C99, so defining it means that POSIX can override anything the C99 standard says.
Eli, what is the basis of your remarks?
1) I've searched the current publically available C99 standard (WG14 N1256 [C99 + TC1 + TC2 + TC3] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf, referenced from http://www.open-std.org/jtc1/sc22/wg14/www/standards) and I see no references to _POSIX_C_SOURCE, either as a reserved identifier, or otherwise. In fact the only reference to POSIX at all is found in the Bibliography [entry 16] and refers only to Part II: Shell and Utilities. If C99 had anything to say about POSIX as a standard, I would expect to find a reference to it in section 2 Normative References, or at least in the Appendices as informative references.
C99 7.1.3p1 "All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use."
That clause has been in the C standard since C89. It has nothing what ever to do with C99, specifically, and it simply refers to the fact that the compiler vendor may define identifiers beginning with underscore for any purpose they wish without concern that they may be breaking existing code bases. What does this have to do with the discussion at hand? It certainly lends no credence to your arguments that all library symbols (functions and global data) defined by POSIX are automatically incorporated into the C99 standard if this symbol is defined and C99 has to honor those symbols.
2) Even if _POSIX_C_SOURCE was a reserved identifier (which you can see from my first point is not true at all), it still would not follow that POSIX can override anything the C99 standard says.
C99 7.1.3p2 "If the program [,,,] defines a reserved identifier as a macro name, the behavior is undefined.
All this clause says is that programs that define identifiers with leading underscores may find themselves broken in the next release of the compiler. Again I ask - what does this have to do with our discussion of the possible ramifications of requesting both C99 compliance _and_ POSIX functionality on the same command line? M?ns' last answer was the most reasonable so far: It works in non-cross gcc, so it should work in cross gcc environments. But please don't try to persuade me that this gray-area functionality is somehow part of the C99 standard. C99 and POSIX have nothing to do with each other, except that POSIX makes the statement that all library functions defined by C99 are incorporated into POSIX. This simply states that C99 is a proper _subset_ of POSIX 2001. My original argument was: If C99 is indeed a proper subset of POSIX, and ffmpeg needs POSIX functionality, then why confuse things by asking the compiler to restrict your code base to C99 with one flag (--std=c99) and then turn around and ask it to also give you access to all POSIX 2001 functionality (as superset of C99) with another flag? One responder suggested that --std=c99 had only to do with language features. This isn't really true, as this flag also affects internal preprocessor variables (that begin with underscores) that _disable_ various functions from the standard library too. Furthermore, without the use of this option, the compiler will allow you access to the full gamut of functionality provided by the compiler. Thus, the ONLY reason to use it is to _restrict_ your code base to a particular standard. John
On Jul 11, 2010, at 4:33 PM, John Calcote wrote:
On 7/10/2010 11:11 PM, David Conrad wrote:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
> John Calcote <john.calcote at gmail.com> writes: > > >> Anyone ever tried compiling ffmpeg under mingw-cross-env >> (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and >> I've found the following issues with CPPFLAGS in the generated config.mak: >> >> 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is >> enabled if -std=c99 is used which means functions like strcasecmp aren't >> available (at least the prototypes aren't). >> >> >> > Wrong. strcasecmp() is part of C99 and on any conforming system is > declared when using those flags. > > > I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
So in this case it's mingw that's wrong.
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
David, your statement is 100 percent true but you missed my point entirely. Basically, -std=c99 and _POSIX_C_SOURCE=200112L are conflicting flags that, when used together, give undefined results. It's cool that the results you've gotten so far are what you wanted, but you can't count on those results on all platforms because the results of using the two together is not defined by any standard.
They aren't. You're mistaken in thinking that -std=c99 is intended to prevent you from using anything not in C99. It's a gcc flag used to select a base language standard. [1] gcc uses to disable incompatible language extensions and select the appropriate warnings; it still leaves in the compatible ones. gcc also defines __STRICT_ANSI__ with -std=c99, which header files may use to hide symbols not in C99. However as I pointed out, POSIX requires that if _POSIX_C_SOURCE is defined, POSIX headers must declare POSIX functions regardless of other macro definitions, including __STRICT_ANSI__. Even without _POSIX_C_SOURCE, gcc does not require libc headers to hide anything when __STRICT_ANSI__ is defined, and obviously C99 itself says nothing about this. [1] http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/C-Dialect-Options.html
On 7/11/2010 11:01 PM, David Conrad wrote:
On Jul 11, 2010, at 4:33 PM, John Calcote wrote:
On 7/10/2010 11:11 PM, David Conrad wrote:
On Jul 11, 2010, at 12:55 AM, John Calcote wrote:
On 7/10/2010 3:10 PM, Eli Friedman wrote:
On Sat, Jul 10, 2010 at 1:57 PM, Ramiro Polla <ramiro.polla at gmail.com> wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
> On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote: > > > >> John Calcote <john.calcote at gmail.com> writes: >> >> >> >>> Anyone ever tried compiling ffmpeg under mingw-cross-env >>> (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and >>> I've found the following issues with CPPFLAGS in the generated config.mak: >>> >>> 1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is >>> enabled if -std=c99 is used which means functions like strcasecmp aren't >>> available (at least the prototypes aren't). >>> >>> >>> >>> >> Wrong. strcasecmp() is part of C99 and on any conforming system is >> declared when using those flags. >> >> >> >> > I'm not seeing strcasecmp as being part of C99. I'm seeing it as being > part of POSIX 2001... Are you sure you're correct on this one? When I > google search strcasecmp and c99, I get very little information on the > pair. However, most of what I do get appear to be comments about how > ffmpeg doesn't compile under mingw. > > > 'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
strcasecmp is defined in strings.h, which is not part of C99. So -std=c99 vs. -std=gnu99 shouldn't have any affect.
I don't think this is an accurate assessment of the way these flags work. In the first place, gnu99 is technically less restrictive than c99. However, the real issue, in my experience, with compiler flags that ask for compliance with a standard is that they tend to be compound-restrictive, not compound-additive. That is to say these flags are designed to ensure that only the subset of library routines that comply with the requested standard are available, and that uses of all other routines are flagged as errors.
To put it another way, they're not designed to provide access to a specific set of functions, but to disallow anything outside the desired set. The reason for this approach is that the flags are designed to help developers write portable code. If you know that three target platform tool sets all conform to C99, and you use the --std=c99 flag on the gcc command line, then you're telling gcc that you don't want to allow anything _except_ C99-compliant functions, not that you want to ensure that you have access to all C99 functions. That way, you can be sure your code will compile on your other two platforms.
Thus, if you supply flags that say you want C99 _and_ POSIX 2001, you're likely (on some platforms, at least) to get the intersection of the two sets, not the union of them. Often this situation goes unnoticed because the these two sets overlap to a high degree (in fact C99 is completely contained within POSIX 2001).
strcasecmp is required to be in POSIX 2001 [1], and if you define _POSIX_C_SOURCE to 200112L then #include <strings.h> is required to make said symbol visible [2].
So in this case it's mingw that's wrong.
[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html [2] http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
David, your statement is 100 percent true but you missed my point entirely. Basically, -std=c99 and _POSIX_C_SOURCE=200112L are conflicting flags that, when used together, give undefined results. It's cool that the results you've gotten so far are what you wanted, but you can't count on those results on all platforms because the results of using the two together is not defined by any standard.
They aren't. You're mistaken in thinking that -std=c99 is intended to prevent you from using anything not in C99. It's a gcc flag used to select a base language standard. [1] gcc uses to disable incompatible language extensions and select the appropriate warnings; it still leaves in the compatible ones.
This paragraph is completely self-contradictory: 1) "You're mistaken in thinking that -std=c99 is intended to prevent you from using anything not in C99." 2) "gcc uses [it] to *disable incompatible language extensions* and select the appropriate warnings; it still leaves in the compatible ones" Can you not see that these two statements are direct contradictions of each other? Part 2 is exactly what I'm saying: the -std flag is used to *disable* anything the compiler would normally support that's not part of the specified standard.
gcc also defines __STRICT_ANSI__ with -std=c99, which header files may use to hide symbols not in C99. However as I pointed out, POSIX requires that if _POSIX_C_SOURCE is defined, POSIX headers must declare POSIX functions regardless of other macro definitions, including __STRICT_ANSI__.
while -std=c99 disables language extensions, __STRICT_ANSI__ is a macro defined by the compiler (when the -std option is used) to facilitate disabling library extensions to the standard. Thus, -std=c99 is a mechanism used purely to disabled language extensions AND library extensions to the C99 standard.
Even without _POSIX_C_SOURCE, gcc does not require libc headers to hide anything when __STRICT_ANSI__ is defined, and obviously C99 itself says nothing about this.
This statement is nonsensical - gcc doesn't require anything - if it did, who would be the party from which something is required? gcc is self-contained - it provides a switch with certain semantics: language and library extensions to the target standard are disabled when the switch is used. The use of _POSIX_C_SOURCE in conjunction with -std=c99 is irrelevant; the two options have nothing to do with one another. The result of using them together is a gray area, which I doubt very much can be shown by any standard to mean any particular thing. In fact, it's pure nonsense to use them together. On the one hand, you're saying "compiler, please restrict my options in the language to just those allowed by C99". On the other hand, you're saying, "compiler, please allow me to use more than the C99 standard allows." This is my whole point: using them together is undefined in the context of any one standard, and therefore makes no sense. gcc chose to do one thing with them, another vendor can chose to do something else. John
On Sat, Jul 10, 2010 at 05:57:58PM -0300, Ramiro Polla wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. ?strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
That is the other way around from what the question is though, and my man page only list strcmp as part of C99, not strcasecmp. However we set the defines to request POSIX, and FFmpeg in general requires POSIX. However, I am quite convinced that all uses (except in ffsever) of strcasecmp in FFmpeg are just plain _wrong_ and will break things if a calling application uses setlocale. For example, with TR_tr locale, if (!strcasecmp(m->elems[j].key, "provider_name")) will not match provIder_name. I seriously doubt this can be considered correct behaviour,
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
On Sat, Jul 10, 2010 at 6:14 PM, Reimar D?ffinger <Reimar.Doeffinger at gmx.de> wrote:
On Sat, Jul 10, 2010 at 05:57:58PM -0300, Ramiro Polla wrote:
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
That is the other way around from what the question is though, and my man page only list strcmp as part of C99, not strcasecmp.
on ubuntu 'man strcasecmp' says "CONFORMING TO 4.4BSD, POSIX.1-2001." on mac os it's a bit more thorough: The strcasecmp() and strncasecmp() functions first appeared in 4.4BSD. Their prototypes existed previously in <string.h> before they were moved to <strings.h> for IEEE Std 1003.1-2001 (``POSIX.1'') compliance.
Ramiro Polla <ramiro.polla at gmail.com> writes:
On Sat, Jul 10, 2010 at 6:14 PM, Reimar D?ffinger <Reimar.Doeffinger at gmx.de> wrote:
However, I am quite convinced that all uses (except in ffsever) of strcasecmp in FFmpeg are just plain _wrong_ and will break things if a calling application uses setlocale. For example, with TR_tr locale, if (!strcasecmp(m->elems[j].key, "provider_name")) will not match provIder_name. I seriously doubt this can be considered correct behaviour,
So are we going to have av_strcasecmp()? =)
http://git.mansr.com/?p=ffmpeg.mru;a=commitdiff;h=0dc41ad1923 -- M?ns Rullg?rd mans at mansr.com
On Sat, Jul 10, 2010 at 10:22:01PM +0100, M?ns Rullg?rd wrote:
Ramiro Polla <ramiro.polla at gmail.com> writes:
On Sat, Jul 10, 2010 at 6:14 PM, Reimar D?ffinger <Reimar.Doeffinger at gmx.de> wrote:
However, I am quite convinced that all uses (except in ffsever) of strcasecmp in FFmpeg are just plain _wrong_ and will break things if a calling application uses setlocale. For example, with TR_tr locale, if (!strcasecmp(m->elems[j].key, "provider_name")) will not match provIder_name. I seriously doubt this can be considered correct behaviour,
So are we going to have av_strcasecmp()? =)
http://git.mansr.com/?p=ffmpeg.mru;a=commitdiff;h=0dc41ad1923
That is quite funny in this context, by using tolower it still has exactly the same issues. av_strcasecmp_ascii with while (1) { int delta = *s - *d; if (!*s || (delta && (delta != 'a' - 'A' || *s < 'a' || *s > 'z') && (delta != 'A' - 'a' || *s < 'A' || *s > 'Z'))) return delta; s++; d++; } should avoid it and would be faster.
Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
On Sat, Jul 10, 2010 at 10:22:01PM +0100, M?ns Rullg?rd wrote:
Ramiro Polla <ramiro.polla at gmail.com> writes:
On Sat, Jul 10, 2010 at 6:14 PM, Reimar D?ffinger <Reimar.Doeffinger at gmx.de> wrote:
However, I am quite convinced that all uses (except in ffsever) of strcasecmp in FFmpeg are just plain _wrong_ and will break things if a calling application uses setlocale. For example, with TR_tr locale, if (!strcasecmp(m->elems[j].key, "provider_name")) will not match provIder_name. I seriously doubt this can be considered correct behaviour,
So are we going to have av_strcasecmp()? =)
http://git.mansr.com/?p=ffmpeg.mru;a=commitdiff;h=0dc41ad1923
That is quite funny in this context, by using tolower it still has exactly the same issues.
Indeed. I just happened to have the patch sitting around.
av_strcasecmp_ascii with while (1) { int delta = *s - *d; if (!*s || (delta && (delta != 'a' - 'A' || *s < 'a' || *s > 'z') && (delta != 'A' - 'a' || *s < 'A' || *s > 'Z'))) return delta; s++; d++; } should avoid it and would be faster.
This looks simpler: #define ascii_tolower(c) ((c) | ((unsigned)((c)-'A') < 'Z'-'A')<<5) All assuming ascii is what we care about of course. -- M?ns Rullg?rd mans at mansr.com
Hi Ramiro, On 7/10/2010 2:57 PM, Ramiro Polla wrote:
On Sat, Jul 10, 2010 at 5:53 PM, John Calcote <john.calcote at gmail.com> wrote:
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
'man standards' says: "POSIX.1-2001 is aligned with C99, so that all of the library functions standardised in C99 are also standardised in POSIX.1-1001."
That's reverse logic. Just because all of C99 is part of POSIX 2001, doesn't mean all of POSIX 2001 is part of C99. The original point was that strcasecmp is part of POSIX 2001, but not necessarily part of C99. The original problem was due to the fact that strcasecmp was being used in a standards-compliant C99 environment. Listen folks, I'm not trying to be "right" about anything here. I'm just trying to solve a problem and (within the limits of reason) I don't really care how it gets solved. My original post was more a query than anything else about what the rest of the community is doing about these issues. So far, all I'm hearing on this list is that the ffmpeg code base is right and everyone else is wrong. That's not very helpful. I took a look at the previously referenced defects that were closed with will-not-fix on the mingw list. I'm not saying the mingw folks are right, nor am I saying they're smarter than this community. But they work on compilers and this community works on video and audio conversion software. It wouldn't hurt to give them a listen - they might have a valid point. Regards, John
John Calcote <john.calcote at gmail.com> writes:
M?ns,
On 7/10/2010 1:25 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
Wrong. strcasecmp() is part of C99 and on any conforming system is declared when using those flags.
I'm not seeing strcasecmp as being part of C99. I'm seeing it as being part of POSIX 2001... Are you sure you're correct on this one? When I google search strcasecmp and c99, I get very little information on the pair. However, most of what I do get appear to be comments about how ffmpeg doesn't compile under mingw.
Sorry, it seems I had it confused with something else. Nevertheless, if it has POSIX functions and we ask for POSIX, why doesn't it supply them?
2) I had to remove the definition of _POSIX_C_SOURCE=200112 because defining it causes pid_t to not be defined in sched.h.
Wrong again. We do not use sched.h at all. We include sys/wait.h, which defers to sys/types.h for the pid_t type. The standard requires that sys/types.h define pid_t with no extra conditions imposed.
You're probably unaware of how pid_t is defined through sched.h via mingw's pthread.h file. I'm not trying to tell you you're wrong - I'm sure this is a very platform (mingw) specific thing.
How mingw defines pid_t is none of my concern. Since it, apparently, does have the unistd.h and sys/wait.h headers, it is insane of it not to define the types these are _required_ to provide by the standard they came from in the first place (I realise mingw is not a full POSIX environment).
After making these changes in the generated config.mak file, ffmpeg and utilities compiled - not cleanly, mind you, but at least as cleanly as it does in normal non-cross builds.
What is that supposed to mean? Condescending remarks like that will not win our hearts.
I'm sorry. I really didn't mean to sound condescending. I can see how it came across that way. I was simply trying to say that there aren't any more warnings than there normally are. Please accept my apologies.
Warnings != unclean. Those who insist on having no warnings have obviously never written code to be compiled with over a dozen different compilers. Keeping them all warning-free at the same time is generally impossible. -- M?ns Rullg?rd mans at mansr.com
On 7/10/2010 3:10 PM, M?ns Rullg?rd wrote:
John Calcote <john.calcote at gmail.com> writes:
2) I had to remove the definition of _POSIX_C_SOURCE=200112 because defining it causes pid_t to not be defined in sched.h.
Wrong again. We do not use sched.h at all. We include sys/wait.h, which defers to sys/types.h for the pid_t type. The standard requires that sys/types.h define pid_t with no extra conditions imposed.
You're probably unaware of how pid_t is defined through sched.h via mingw's pthread.h file. I'm not trying to tell you you're wrong - I'm sure this is a very platform (mingw) specific thing.
How mingw defines pid_t is none of my concern. Since it, apparently, does have the unistd.h and sys/wait.h headers, it is insane of it not to define the types these are _required_ to provide by the standard they came from in the first place (I realise mingw is not a full POSIX environment).
They may very well have a problem. I'll approach them on the cross-env mailing list and see if they're aware of it and what they have to say about it.
After making these changes in the generated config.mak file, ffmpeg and utilities compiled - not cleanly, mind you, but at least as cleanly as it does in normal non-cross builds.
What is that supposed to mean? Condescending remarks like that will not win our hearts.
I'm sorry. I really didn't mean to sound condescending. I can see how it came across that way. I was simply trying to say that there aren't any more warnings than there normally are. Please accept my apologies.
Warnings != unclean. Those who insist on having no warnings have obviously never written code to be compiled with over a dozen different compilers. Keeping them all warning-free at the same time is generally impossible.
Yes, I agree. I wasn't even trying to imply ffmpeg was unclean - only that the set of warnings I got in my mingw env was comparable to a non-cross build. I don't think I ever said it was unclean. But (again) I certainly see how my original remarks could have been taken as abrasive. Again, I'm sorry. Thanks for the feedback. John
Hi, On Sat, Jul 10, 2010 at 4:06 PM, John Calcote <john.calcote at gmail.com> wrote:
Anyone ever tried compiling ffmpeg under mingw-cross-env (http://www.nongnu.org/mingw-cross-env/)? I've been playing with it and I've found the following issues with CPPFLAGS in the generated config.mak:
1) I had to change -std=c99 to -std=gnu99 because _STRICT_ANSI is enabled if -std=c99 is used which means functions like strcasecmp aren't available (at least the prototypes aren't).
https://roundup.ffmpeg.org/issue2067 Note that they've closed their issue as invalid, so it's unlikely to be fixed (as in you'll have to patch your system).
2) I had to remove the definition of _POSIX_C_SOURCE=200112 because defining it causes pid_t to not be defined in sched.h.
This is a bug in pthreads-win32, which is fixed in their CVS HEAD if I recall correctly. Any reason why you can't use w32threads?
I used the following command line to configure:
$ configure --enable-postproc --enable-gpl --enable-x11grab --enable-pthreads --enable-nonfree --enable-libvorbis --target-os=mingw32 --enable-memalign-hack --arch=x86_64 --cross-prefix=i686-pc-mingw32-
Note this is a 64-bit windows build (arch=x86_64).
After making these changes in the generated config.mak file, ffmpeg and utilities compiled - not cleanly, mind you, but at least as cleanly as it does in normal non-cross builds.
Any comments would be appreciated. Perhaps I'm doing something fundamentally wrong in my cross compile?
mingw32 doesn't support x86_64, so this is fundamentally broken. You should use mingw-w64 instead. Did you even try running 'make test' on the native build? Also note that since this is an usage question, it should be sent to the ffmpeg-user mailinglist (if you reply, please reply to that list, and not to ffmpeg-devel). Ramiro Polla
participants (6)
-
eli.friedman@gmail.com -
john.calcote@gmail.com -
lessen42@gmail.com -
mans@mansr.com -
ramiro.polla@gmail.com -
Reimar.Doeffinger@gmx.de