[Challenge] implementing the ambiguous operator in D
bearophile
bearophileHUGS at lycos.com
Sun Sep 5 09:18:13 PDT 2010
Denis Koroskin:
> Turn main into an "extern(C) int main()" and it works.
This version:
import std.c.stdio: puts;
version (Windows) {
alias int[16] jmp_buf;
extern (C) extern {
int setjmp(ref jmp_buf env);
void longjmp(ref jmp_buf env, int value);
}
}
struct State {
int save() {
return setjmp(buf);
}
void restore(int status) {
assert(status != 0);
longjmp(buf, status);
}
private jmp_buf buf;
}
extern(C) int main() {
State state;
int result = state.save();
if (result == 0) {
// first time here
puts("state saved");
state.restore(1);
} else {
assert(result == 1);
puts("state restored");
}
return 0;
}
Gives link errors:
test.obj(test)
Error 42: Symbol Undefined __d_assertm
test.obj(test)
Error 42: Symbol Undefined __d_assert_msg
Bye,
bearophile
More information about the Digitalmars-d
mailing list