Questions tagged [opaque-pointers]

In computer programming, an opaque pointer is a special case of an opaque data type, a datatype declared to be a pointer to a record or data structure of some unspecified type.

Opaque pointers are a way to hide the implementation details of an interface from ordinary clients, so that the implementation may be changed without the need to recompile the modules using it. This benefits the programmer as well since a simple interface can be created, and most details can be hidden in another file. This is important for providing binary code compatibility through different versions of a shared library, for example.

86 questions
1
vote
0 answers

Does LLVM ever care about the difference between opaque types?

According to https://llvm.org/docs/LangRef.html#opaque-structure-types Opaque structure types are used to represent structure types that do not have a body specified. This corresponds (for example) to the C notion of a forward declared structure.…
rwallace
  • 31,405
  • 40
  • 123
  • 242
1
vote
2 answers

How do I properly use a dynamically-allocated opaque pointer in a scoped pointer class?

Background I'm working with the Intel IPP Cryptographic Libraries for testing. They define several opaque structs used for shared contexts over things like hashing and encryption which, of course, cannot be directly instantiated. To initialize one…
Mark Cohen
  • 13
  • 2
1
vote
3 answers

aliasing issue with OO inheritance in C

I'm doing inheritance ( i.e. calling super class's function with subclass data type) with C, but encountered the aliasing issue. In below, shape function is called with rectangle object. In the case of me->super, the x and y are correct. However,…
1
vote
1 answer

Storing OpaquePointer type in UserDefaults

I am working on Xcode 12 and Swift 5 environment to build an iOS application. I need to store an OpaquePointer type variable("self.loggers" in the code below) before the view disappears(or before the app closes) and retrieve it when the view…
1
vote
0 answers

Return an Opaque object in C#

I'm not very familiar with C# and I've not been able to find a reasonable answer anywhere. I simply want to return an object from a function that to the caller is opaque. I still want the user to be able to pass the object around, I just don't…
The Welder
  • 916
  • 6
  • 24
1
vote
3 answers

Opaque pointer not accessable from resident .c file

I am getting a weird segmentation fault when accessing a structure inside of a opaque structure form it's definition file. I have just recently learned about opaque pointers, but my my guess is, I am doing something wrong with the allocation of the…
siery
  • 467
  • 3
  • 20
1
vote
1 answer

memcpy() on struct member casted from an opque pointer

Let's say I have an API: // api.h - Others can #include this header #include class A { public: // Write data into an opaque type. // The user shouldn't directly access the underlying bits of this value. // They should use this…
BrockLee
  • 931
  • 2
  • 9
  • 24
1
vote
1 answer

Why can't I create an opaque data type?

I'm trying to experiment with opaque data types to get an understanding of them. The main problem is that I keep getting an 'incomplete' error. main.c #include #include #include "blepz.h" int main() { setfnarp(GOO,5); …
thepufferfish
  • 441
  • 4
  • 17
1
vote
1 answer

Opaque struct that has some private operations

I'm designing a library and came to an issue about separating operations that are public and library private. I have the following library interface: libmylib.h: typedef struct lib_context lib_context; int init_library_context(const char **paths, …
St.Antario
  • 26,175
  • 41
  • 130
  • 318
1
vote
3 answers

How to print a double pointer value in C

we are implementing a priority queue for generic type of datas in C. We think the assignments between pointers etc. are made right, but we don't get how to print at the end the int value of "element". Can you help me? #include…
palnic
  • 386
  • 1
  • 4
  • 13
1
vote
2 answers

How to delete head node in linked list? C

So I have a linked list stack as an opaque object in C. am passing in a head pointer pointer to the function. this is the code for the delete head function. am calling it pop MY_STACK pop(MY_STACK* head) { Node_ptr hHead = (Node_ptr)head; …
jobobdsfos
  • 19
  • 1
  • 4
1
vote
2 answers

Am I correct to assume one cannot forward-declare a library's opaque pointer type?

There are a lot of questions out there about forward declarations and opaque types, but most seem to be from the perspective of the library author, or people trying to use incomplete types without pointers or some such. I'm using a library whose…
J Cooper
  • 16,891
  • 12
  • 65
  • 110
1
vote
1 answer

Should an opaque pointer be implemented using an unnamed struct or an undefined tag?

I am currently designing an API that allows the user to pass an opaque pointer that he will be passed back later on when the methods of an interface he has to implement are called. This basically goes down to the following: API-side: class…
HiroshimaCC
  • 486
  • 4
  • 11
1
vote
3 answers

C++ Communicating private data from opaque pointer

I've recently learned about opaque pointers in C++. I've started using them to hide private members that are platform specific. Such as references to definitions in etc. Now, I have several systems that build off each other and need to…
Nathan Goings
  • 1,145
  • 1
  • 15
  • 33
0
votes
0 answers

How to reserve "type opaque" in IR file of LLVM 15

I try to compile a cpp file into a ir file by clang. And there is a definition of struct pointer in cpp file, like "struct structType *p", and the value or element of p is never visited. AS a result, the IR file compiled by LLVM15 don't contain any…