I have this struct outside my module, in my C++ implementation:
struct A {
int a;
};
How I can create this function which takes an A pointer and change it? like:
define void @func(%struct.A*) {
%2 = alloca %struct.A*, align 8
store %struct.A* %0, %struct.A** %2, align 8
...
}
Or it is not possible? I need to create a struct in my module and update the external one?
Yes, type declarations should be present in every module they are used. It is the same for C++ - you can't use struct A
if you don't have it declared in the source, or any includes.
However, you seem to be operating on pointer to that structure in your code. AFAIK, in this case it is safe to declare an empty structure and use a pointer to that.