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 21:11

It's broken because it does not propagate.

typedef struct box {
  int* p;
} box_t;

void func(const box_t* box) {
  box->p[0] = 5; // WTF NO ERROR!! hax mah box
};


Here's another example:

void func(const std::vector<const Box>);

int main() {
  func(std::vector<Box>()); // ERROR, incompatible types
}


It's broken because attempts to fix it (in sepples) cause code duplication due to permutations of const arguments ('const-overloading').

class BoxList {
const Box& operator[] (int i) const;
      Box& operator[] (int i);
}


It's even more broken in C because the above hacks aren't allowed.

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