Last active
August 10, 2018 10:03
-
-
Save hkdnet/0176340f10b71ef2a7262e2680645e5d to your computer and use it in GitHub Desktop.
union の deconst 外すやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/iseq.c b/iseq.c | |
index 997dd7f1f7..be9efb9aad 100644 | |
--- a/iseq.c | |
+++ b/iseq.c | |
@@ -989,11 +989,8 @@ static const rb_data_type_t iseqw_data_type = { | |
static VALUE | |
iseqw_new(const rb_iseq_t *iseq) | |
{ | |
- union { const rb_iseq_t *in; void *out; } deconst; | |
VALUE obj; | |
- | |
- deconst.in = iseq; | |
- obj = TypedData_Wrap_Struct(rb_cISeq, &iseqw_data_type, deconst.out); | |
+ obj = TypedData_Wrap_Struct(rb_cISeq, &iseqw_data_type, (void *)iseq); | |
RB_OBJ_WRITTEN(obj, Qundef, iseq); | |
return obj; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int bar(void* b) { | |
return 1; | |
} | |
void tekitou(char* a) | |
{ | |
bar((void *)a); | |
} | |
int main(int argc, char const* argv[]) | |
{ | |
tekitou("aiueo"); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ clang -Wcast-qual foo.c -o foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment