Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make int8_t from c to int8 in golang? #131

Open
TheFern2 opened this issue Oct 6, 2022 · 1 comment
Open

How to make int8_t from c to int8 in golang? #131

TheFern2 opened this issue Oct 6, 2022 · 1 comment

Comments

@TheFern2
Copy link

TheFern2 commented Oct 6, 2022

Just finished running some golang tests after the autogeneration, I found one function where int8_t is getting turned into a byte instead of int8. How do you specify in the yml to make int8_t to int8, I read the docs but I couldn't understand how to do it. Or is this another custom header type of issue?

LIB_EXPORT int8_t plc_tag_get_int8(int32_t tag, int offset);
LIB_EXPORT int plc_tag_set_int8(int32_t, int offset, int8_t val);

Here if I change byte to int8 on GetInt8 return, and SetInt8 val, then the tests pass.

// GetInt8 function as declared in include/libplctag.h:492
func GetInt8(tag int32, offset int32) byte {
	ctag, ctagAllocMap := (C.int32_t)(tag), cgoAllocsUnknown
	coffset, coffsetAllocMap := (C.int)(offset), cgoAllocsUnknown
	__ret := C.plc_tag_get_int8(ctag, coffset)
	runtime.KeepAlive(coffsetAllocMap)
	runtime.KeepAlive(ctagAllocMap)
	__v := (byte)(__ret)
	return __v
}

// SetInt8 function as declared in include/libplctag.h:493
func SetInt8(arg0 int32, offset int32, val byte) int32 {
	carg0, carg0AllocMap := (C.int32_t)(arg0), cgoAllocsUnknown
	coffset, coffsetAllocMap := (C.int)(offset), cgoAllocsUnknown
	cval, cvalAllocMap := (C.int8_t)(val), cgoAllocsUnknown
	__ret := C.plc_tag_set_int8(carg0, coffset, cval)
	runtime.KeepAlive(cvalAllocMap)
	runtime.KeepAlive(coffsetAllocMap)
	runtime.KeepAlive(carg0AllocMap)
	__v := (int32)(__ret)
	return __v
}
@TheFern2
Copy link
Author

TheFern2 commented Oct 6, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant