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
0
votes
3 answers

How do you declare a distinct type in C?

Background I am working with a collection of opaque types of my own design ("the collection"). At higher levels of my program, I want to pass around handles to each instance of each object having a type in the collection. The lower levels of my…
Ana Nimbus
  • 635
  • 3
  • 16
0
votes
1 answer

How to pass different structure in a single function as argument

I have 2 structure name struct1, struct2. also i have one manipulation function named "myFun" void myFun(/one pointer argument/) i have a set flag , if set flag is 1 i need to pass struct1 pointer as myFun argument if set flag is 0 i need to pass…
0
votes
1 answer

Opaque struct in C++ as class member

I have not been able to find an answer on this, but my case is: // vulkan_glfw_backend.hpp struct alignas(8) VulkanGlfwWindowContext; class MY_API VulkanGlfwBackend { // [...] private: VulkanGlfwWindowContext* mpContext; }; And the source…
alexpanter
  • 1,222
  • 10
  • 25
0
votes
3 answers

How to disable integer assignment (0) to an opaque variable?

I have a module whose implementation I want to hide from its clients. I chose to declare an opaque type which is actually a pointer to structure to be defined only in the implementation. It all is working fine, except that I can assign the zero…
amso
  • 514
  • 1
  • 6
  • 14
0
votes
3 answers

How do you write generic list without knowing the implementation of structure?

Let's assume there is an employee ADT, such as //employee.h typedef struct employee_t employee_t; employee_t* employee_create(char* company, char* department, char* position); void employee_free(employee_t* me); , and client code would…
0
votes
0 answers

How do I access the members of an opaque data struct in C when it is passed by double reference to a set function?

I'm new to C and I'm working with an opaque data structure passed by double reference. I've declared the struct prototype in cars.h as typedef struct car car. In cars.c I then go on to define the struct with the following members: struct car{char…
0
votes
2 answers

How to correctly define inline functions that handle opaque pointers?

How do I correctly define an inline function that dereferences an opaque pointer according to the C99 standard? Let's say I've organized a program in three files: opaq.h: typedef struct Opaq Opaq; Opaq* opaq_init(void* ptr, int size); void…
Nick
  • 260
  • 3
  • 11
0
votes
4 answers

Using C++ objects from Obj-C / Obj-C++ -- Calling external methods

I'm using C++ objects in an Obj-C code. To do this, I've wrapped the C++ objects in ObjC objects, which in turn use opaque pointers to access the C++ classes. That stuff is working. the Problem: The C++ objects (e.g. CPPObj.cc) use methods from…
DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119
0
votes
0 answers

How to wrapping in C a C++ function with vector output argument?

I'm coding a C wrapper and need to get data from a vector of struct. struct and functio to wrap struct foo { string name; time_t datetime; string uid; int number_id; string store; string city; …
crossmax
  • 346
  • 3
  • 20
0
votes
1 answer

Iterator providing a "view" of its current element

The design issue I'm currently solving is to iterate over some region of memory and on each such iteration retrieve from that memory some meta-data the client is interested in. I see 2 solutions currently: I. struct queue; struct…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
0
votes
2 answers

How to include opaque type in multiple .c files?

I am supposed to make a program based on a header file and some further description. The problem working with opaque type is needed. Opaque struct is declared in header file with some other functions. But each function is supposed to have its own .c…
Maraz
  • 82
  • 9
0
votes
2 answers

How do I see inside opaque data types?

I know this kind of goes against the whole point of opaque data types, but for the purpose of reverse engineering, how do people go about looking into opaque data types?
0
votes
0 answers

SQL syntax error throwing near "CLUSTERED": syntax error

While loading sql query its throwing error near "CLUSTERED": syntax error import SQLite3 var db: OpaquePointer? let fileURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) …
Amit
  • 556
  • 1
  • 7
  • 24
0
votes
1 answer

Opaque Pointer error Swift 3.1

I am having an issue with foreign and international characters inserted or updated into a SQLite database using Swift 3.1. So, I tried the below to add the UTF8, but run into an error " cannot convert value of type 'string' to expected argument type…
David Sanford
  • 735
  • 12
  • 26
0
votes
2 answers

typedef opaque pointer to opaque pointer

I got the following code: // file external_module.h typedef externaldata * externalhdl; // opaque pointer externalhdl external_Create(); // file internal_module.h typedef internaldata * internalhdl; // opaque pointer internalhdl…
Schafwolle
  • 501
  • 3
  • 15