Why does -std=c11 with gcc hide popen in stdio.h? [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
popen implicitly declared even though #include <stdio.h> is added
3 answers
I want to use popen. It is in stdio.h. I include that, but the compiler doesn't see it with
-std=c11. It does compile without -std=c11.
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
gcc -std=c11 popen_test.c
popen_test.c: In function ‘main’:
popen_test.c:5:4: warning: implicit declaration of function ‘popen’ [-Wimplicit-function-declaration]
popen("ls *","r");
^~~~~
It is hidden in stdio.h with
#ifdef __USE_POSIX2
The man page says it is available if:
_POSIX_C_SOURCE >= 2 || /* Glibc versions <= 2.19: */
_BSD_SOURCE || _SVID_SOURCE
c popen
marked as duplicate by tmlen, melpomene
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 10 at 20:19
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
popen implicitly declared even though #include <stdio.h> is added
3 answers
I want to use popen. It is in stdio.h. I include that, but the compiler doesn't see it with
-std=c11. It does compile without -std=c11.
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
gcc -std=c11 popen_test.c
popen_test.c: In function ‘main’:
popen_test.c:5:4: warning: implicit declaration of function ‘popen’ [-Wimplicit-function-declaration]
popen("ls *","r");
^~~~~
It is hidden in stdio.h with
#ifdef __USE_POSIX2
The man page says it is available if:
_POSIX_C_SOURCE >= 2 || /* Glibc versions <= 2.19: */
_BSD_SOURCE || _SVID_SOURCE
c popen
marked as duplicate by tmlen, melpomene
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 10 at 20:19
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
popenis not part of standard C.
– melpomene
Nov 10 at 20:14
@melpomene Can you turn -std=c11 on and off in the source code?
– Scooter
Nov 10 at 20:15
What do you mean by that? Or maybe a better question: What are you trying to achieve by specifying-std=c11?
– melpomene
Nov 10 at 20:16
@melpomene I want all the features of C11
– Scooter
Nov 10 at 20:17
3
Well, e.g.-std=gnu11would give you that plus all GNU extensions.
– melpomene
Nov 10 at 20:17
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
popen implicitly declared even though #include <stdio.h> is added
3 answers
I want to use popen. It is in stdio.h. I include that, but the compiler doesn't see it with
-std=c11. It does compile without -std=c11.
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
gcc -std=c11 popen_test.c
popen_test.c: In function ‘main’:
popen_test.c:5:4: warning: implicit declaration of function ‘popen’ [-Wimplicit-function-declaration]
popen("ls *","r");
^~~~~
It is hidden in stdio.h with
#ifdef __USE_POSIX2
The man page says it is available if:
_POSIX_C_SOURCE >= 2 || /* Glibc versions <= 2.19: */
_BSD_SOURCE || _SVID_SOURCE
c popen
This question already has an answer here:
popen implicitly declared even though #include <stdio.h> is added
3 answers
I want to use popen. It is in stdio.h. I include that, but the compiler doesn't see it with
-std=c11. It does compile without -std=c11.
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
gcc -std=c11 popen_test.c
popen_test.c: In function ‘main’:
popen_test.c:5:4: warning: implicit declaration of function ‘popen’ [-Wimplicit-function-declaration]
popen("ls *","r");
^~~~~
It is hidden in stdio.h with
#ifdef __USE_POSIX2
The man page says it is available if:
_POSIX_C_SOURCE >= 2 || /* Glibc versions <= 2.19: */
_BSD_SOURCE || _SVID_SOURCE
This question already has an answer here:
popen implicitly declared even though #include <stdio.h> is added
3 answers
c popen
c popen
edited Nov 10 at 20:15
asked Nov 10 at 20:11
Scooter
3,51662749
3,51662749
marked as duplicate by tmlen, melpomene
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 10 at 20:19
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by tmlen, melpomene
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 10 at 20:19
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
popenis not part of standard C.
– melpomene
Nov 10 at 20:14
@melpomene Can you turn -std=c11 on and off in the source code?
– Scooter
Nov 10 at 20:15
What do you mean by that? Or maybe a better question: What are you trying to achieve by specifying-std=c11?
– melpomene
Nov 10 at 20:16
@melpomene I want all the features of C11
– Scooter
Nov 10 at 20:17
3
Well, e.g.-std=gnu11would give you that plus all GNU extensions.
– melpomene
Nov 10 at 20:17
add a comment |
popenis not part of standard C.
– melpomene
Nov 10 at 20:14
@melpomene Can you turn -std=c11 on and off in the source code?
– Scooter
Nov 10 at 20:15
What do you mean by that? Or maybe a better question: What are you trying to achieve by specifying-std=c11?
– melpomene
Nov 10 at 20:16
@melpomene I want all the features of C11
– Scooter
Nov 10 at 20:17
3
Well, e.g.-std=gnu11would give you that plus all GNU extensions.
– melpomene
Nov 10 at 20:17
popen is not part of standard C.– melpomene
Nov 10 at 20:14
popen is not part of standard C.– melpomene
Nov 10 at 20:14
@melpomene Can you turn -std=c11 on and off in the source code?
– Scooter
Nov 10 at 20:15
@melpomene Can you turn -std=c11 on and off in the source code?
– Scooter
Nov 10 at 20:15
What do you mean by that? Or maybe a better question: What are you trying to achieve by specifying
-std=c11?– melpomene
Nov 10 at 20:16
What do you mean by that? Or maybe a better question: What are you trying to achieve by specifying
-std=c11?– melpomene
Nov 10 at 20:16
@melpomene I want all the features of C11
– Scooter
Nov 10 at 20:17
@melpomene I want all the features of C11
– Scooter
Nov 10 at 20:17
3
3
Well, e.g.
-std=gnu11 would give you that plus all GNU extensions.– melpomene
Nov 10 at 20:17
Well, e.g.
-std=gnu11 would give you that plus all GNU extensions.– melpomene
Nov 10 at 20:17
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
popen is not part of C. To get it, you need to enable it with a feature test macro before including anything.
The simplest way to do it is with a #define _GNU_SOURCE at the top (or with -D_GNU_SOURCE in your compiler invocation).
compiles with -std=c11:
#define _GNU_SOURCE
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
Does -std=c11 mean "don't allow anything that isn't part of C11"? I was hoping for "allow anything that is part of C11".
– Scooter
Nov 10 at 20:20
1
@Scooter I'd say it's more like that callinggccwithout a specific standards gives you some extra gnu stuff (-std=gnu11or whatever your compiler defaults to).-std=c11disables it so that the identifiers that the C standard says should belong to you aren't taken.
– PSkocik
Nov 10 at 20:23
2
@Scooterint popen; int main(void) { return popen; }is a valid C11 program, but it would conflict with thepopenfunction.
– melpomene
Nov 10 at 20:24
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
popen is not part of C. To get it, you need to enable it with a feature test macro before including anything.
The simplest way to do it is with a #define _GNU_SOURCE at the top (or with -D_GNU_SOURCE in your compiler invocation).
compiles with -std=c11:
#define _GNU_SOURCE
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
Does -std=c11 mean "don't allow anything that isn't part of C11"? I was hoping for "allow anything that is part of C11".
– Scooter
Nov 10 at 20:20
1
@Scooter I'd say it's more like that callinggccwithout a specific standards gives you some extra gnu stuff (-std=gnu11or whatever your compiler defaults to).-std=c11disables it so that the identifiers that the C standard says should belong to you aren't taken.
– PSkocik
Nov 10 at 20:23
2
@Scooterint popen; int main(void) { return popen; }is a valid C11 program, but it would conflict with thepopenfunction.
– melpomene
Nov 10 at 20:24
add a comment |
up vote
1
down vote
popen is not part of C. To get it, you need to enable it with a feature test macro before including anything.
The simplest way to do it is with a #define _GNU_SOURCE at the top (or with -D_GNU_SOURCE in your compiler invocation).
compiles with -std=c11:
#define _GNU_SOURCE
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
Does -std=c11 mean "don't allow anything that isn't part of C11"? I was hoping for "allow anything that is part of C11".
– Scooter
Nov 10 at 20:20
1
@Scooter I'd say it's more like that callinggccwithout a specific standards gives you some extra gnu stuff (-std=gnu11or whatever your compiler defaults to).-std=c11disables it so that the identifiers that the C standard says should belong to you aren't taken.
– PSkocik
Nov 10 at 20:23
2
@Scooterint popen; int main(void) { return popen; }is a valid C11 program, but it would conflict with thepopenfunction.
– melpomene
Nov 10 at 20:24
add a comment |
up vote
1
down vote
up vote
1
down vote
popen is not part of C. To get it, you need to enable it with a feature test macro before including anything.
The simplest way to do it is with a #define _GNU_SOURCE at the top (or with -D_GNU_SOURCE in your compiler invocation).
compiles with -std=c11:
#define _GNU_SOURCE
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
popen is not part of C. To get it, you need to enable it with a feature test macro before including anything.
The simplest way to do it is with a #define _GNU_SOURCE at the top (or with -D_GNU_SOURCE in your compiler invocation).
compiles with -std=c11:
#define _GNU_SOURCE
#include <stdio.h>
int main(void)
{
popen("ls *","r");
}
answered Nov 10 at 20:19
PSkocik
31.2k54568
31.2k54568
Does -std=c11 mean "don't allow anything that isn't part of C11"? I was hoping for "allow anything that is part of C11".
– Scooter
Nov 10 at 20:20
1
@Scooter I'd say it's more like that callinggccwithout a specific standards gives you some extra gnu stuff (-std=gnu11or whatever your compiler defaults to).-std=c11disables it so that the identifiers that the C standard says should belong to you aren't taken.
– PSkocik
Nov 10 at 20:23
2
@Scooterint popen; int main(void) { return popen; }is a valid C11 program, but it would conflict with thepopenfunction.
– melpomene
Nov 10 at 20:24
add a comment |
Does -std=c11 mean "don't allow anything that isn't part of C11"? I was hoping for "allow anything that is part of C11".
– Scooter
Nov 10 at 20:20
1
@Scooter I'd say it's more like that callinggccwithout a specific standards gives you some extra gnu stuff (-std=gnu11or whatever your compiler defaults to).-std=c11disables it so that the identifiers that the C standard says should belong to you aren't taken.
– PSkocik
Nov 10 at 20:23
2
@Scooterint popen; int main(void) { return popen; }is a valid C11 program, but it would conflict with thepopenfunction.
– melpomene
Nov 10 at 20:24
Does -std=c11 mean "don't allow anything that isn't part of C11"? I was hoping for "allow anything that is part of C11".
– Scooter
Nov 10 at 20:20
Does -std=c11 mean "don't allow anything that isn't part of C11"? I was hoping for "allow anything that is part of C11".
– Scooter
Nov 10 at 20:20
1
1
@Scooter I'd say it's more like that calling
gcc without a specific standards gives you some extra gnu stuff (-std=gnu11 or whatever your compiler defaults to). -std=c11 disables it so that the identifiers that the C standard says should belong to you aren't taken.– PSkocik
Nov 10 at 20:23
@Scooter I'd say it's more like that calling
gcc without a specific standards gives you some extra gnu stuff (-std=gnu11 or whatever your compiler defaults to). -std=c11 disables it so that the identifiers that the C standard says should belong to you aren't taken.– PSkocik
Nov 10 at 20:23
2
2
@Scooter
int popen; int main(void) { return popen; } is a valid C11 program, but it would conflict with the popen function.– melpomene
Nov 10 at 20:24
@Scooter
int popen; int main(void) { return popen; } is a valid C11 program, but it would conflict with the popen function.– melpomene
Nov 10 at 20:24
add a comment |
popenis not part of standard C.– melpomene
Nov 10 at 20:14
@melpomene Can you turn -std=c11 on and off in the source code?
– Scooter
Nov 10 at 20:15
What do you mean by that? Or maybe a better question: What are you trying to achieve by specifying
-std=c11?– melpomene
Nov 10 at 20:16
@melpomene I want all the features of C11
– Scooter
Nov 10 at 20:17
3
Well, e.g.
-std=gnu11would give you that plus all GNU extensions.– melpomene
Nov 10 at 20:17