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

Jump to C++functions #3593

Open
ArthurZangCN opened this issue Nov 6, 2024 · 4 comments
Open

Jump to C++functions #3593

ArthurZangCN opened this issue Nov 6, 2024 · 4 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@ArthurZangCN
Copy link

My project is a mixed code project of Golang and C++. Golang calls functions encapsulated in C++, and C++function definitions use the prefix extern "C" func. Golang uses import "C" and calls C.func. Currently, this method has a red wavy line indicating that the definition cannot be found and cannot be jumped.

@gopherbot gopherbot added this to the Untriaged milestone Nov 6, 2024
@ansaba
Copy link

ansaba commented Nov 7, 2024

@ArthurZangCN , can you provide screenshot and more information about what/how you are trying to call ?

@ansaba ansaba added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 7, 2024
@firelizzard18
Copy link
Contributor

@ArthurZangCN I think this is a limitation in the Go compiler. I believe the Go-C translation layer isn't created until you compile your program. Does the problem persist after you compile?

@ArthurZangCN
Copy link
Author

@ArthurZangCN , can you provide screenshot and more information about what/how you are trying to call ?

For example, I have a type conversion function encapsulated in C++that converts Golang's data type to C++'s data type
void* allocFun(int a, int b, int c)
{
... ...
return (struct myDef *)tmp;
}
I have a golang encapsulated API that calls allocFun
import "C"
func prepareA(requestJson []byte) {
// byte to json

var p unsafe.Pointer
p = C.allocFun(C.int(a), C.int(b), C.int(c))

}
For the convenience of management, these cpp and go source codes are placed in the same project directory, but will be compiled separately. In this case, if you jump to allocFun in go, you will not be able to find the definition, and there will be red wavy lines on the page.

@ArthurZangCN
Copy link
Author

@ArthurZangCN I think this is a limitation in the Go compiler. I believe the Go-C translation layer isn't created until you compile your program. Does the problem persist after you compile?

There are no strict language type restrictions for Linux projects. I will mix my C++and Golang languages in the same project directory. Although they will be compiled separately, they will be written simultaneously when writing code. In this case, it would be very convenient to jump from Go to C++defined functions, but now I can only use search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants