Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

-std=c99 my anus

Name: Anonymous 2009-11-25 15:29

[code]$cat test.c
#include <stdlib.h>
#include <string.h>

int main(void) {
    char *foo;
    foo = strdup("bar");
    free(foo);
    return 0;
}
$gcc test.c
$gcc -std=c99 test.c
test.c: In function 'main':
test.c:6: warning: implicit declaration of function 'strdup'
test.c:6: warning: assignment makes pointer from integer without a cast[code]
What the heck is this, /prog/? Is there some shit around strdup() in c99?

Name: Anonymous 2009-11-25 23:46

>>15
The data you are manipulating is not const, your box is.
THAT'S THE PROBLEM. Christ, I know how they fucking work. Why don't you explain to me again what is const?

make your int pointer const, not the box.
No, you can't do that. If you make the int point to const in the struct, then the implementation of the box can't ever modify it. You can't make two boxes (i.e. Box, with int* and ConstBox with const int*) because they're inconvertible.

That's the whole problem, don't you see? There's no way to make a const box where the const is propagated to its pointers. Yes, they fucking work according to the spec, we get it. The spec is BAD. It was a BAD DECISION to make them work the way they do.

But go ahead, explain to me again how the int is not constant but the box is.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List