Skip to main content
Filter by
Sorted by
Tagged with
1 vote
4 answers
200 views

Understanding Opaque Pointers

I apologize if this is an obvious question, but in C, are Opaque Pointers similar to Java Interfaces? As I'm trying to understand them, I'm interpreting them similarly to Java interfaces in the sense ...
RogueGingerz's user avatar
0 votes
0 answers
60 views

How to implement a forward declared opaque type in global fragment?

I'm trying to migrate my library to c++20 module. My library provide C interface with some opaque type. Consider following code: // abc.h typedef struct ABC *ABC_PTR: // abc_impl.h #include "abc....
nekosu's user avatar
  • 77
2 votes
1 answer
115 views

Interfacing std compatibility to opaque data with external evaluation dispatch

I am receiving managed data in a low level { void * data; uint stride, count; } format. I can read, write and swap data items, but not to add or remove / resize / reallocate. There's enough ...
dtech's user avatar
  • 49.2k
2 votes
1 answer
178 views

PyBind11 : share opaque pointers between independently-built C++ modules through Python

I have two PyBind11-linked Python modules which must compile separately (no common headers etc) and I would like to share pointers to a common custom C++ class defined the same way in both modules. I ...
magtweezers's user avatar
0 votes
3 answers
348 views

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 ...
Ana Nimbus's user avatar
0 votes
1 answer
61 views

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 ...
Dhaneesh lal.D.R's user avatar
0 votes
1 answer
322 views

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: ...
alexpanter's user avatar
  • 1,550
1 vote
2 answers
433 views

Struggling with Opaque Pointers in SQLITE swift

Hi I am new to swift and attempting to add a database for my a level coding project. I cannot seem to get opaque pointers to work without errors. I have used tutorials and always get the same errors. ...
Josh Horne's user avatar
1 vote
0 answers
489 views

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) ...
rwallace's user avatar
  • 33.2k
1 vote
3 answers
115 views

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 ...
Mr.nerd3345678's user avatar
0 votes
3 answers
316 views

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(...
Mr.nerd3345678's user avatar
1 vote
1 answer
146 views

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 ...
Aiden0206's user avatar
2 votes
0 answers
301 views

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 ...
The Welder's user avatar
  • 1,052
3 votes
2 answers
95 views

No-copy type annotation

In C, if a structure contains a futex or for whatever reason doesn't make sense to copy or move to a new address, is there any way (type annotation or something) to restrict/warn users from ...
user100046's user avatar
1 vote
3 answers
144 views

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 ...
siery's user avatar
  • 547
0 votes
0 answers
256 views

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 ...
redengineer's user avatar
0 votes
2 answers
254 views

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; ...
Nick's user avatar
  • 308
1 vote
1 answer
174 views

memcpy() on struct member casted from an opque pointer

Let's say I have an API: // api.h - Others can #include this header #include <cstdint> class A { public: // Write data into an opaque type. // The user shouldn't directly access the ...
BrockLee's user avatar
  • 981
2 votes
1 answer
158 views

How does linking work in C with regards to opaque pointers?

So, I've been having a bit of confusion regarding linking of various things. For this question I'm going to focus on opaque pointers. I'll illustrate my confusion with an example. Let's say I have ...
thepufferfish's user avatar
3 votes
3 answers
3k views

C struct information hiding (Opaque pointer)

I'm currently a bit confused regarding the concept of information hiding of C-structs. The backround of this question is an embedded c project with nearly zero knowledge of OOP. Up until now I ...
Evox402's user avatar
  • 111
-3 votes
13 answers
4k views

Value of type 'Category' (aka 'OpaquePointer') has no member 'name'

I'm working with Swift in Xcode and I receive the following error: Value of type 'Category' (aka 'OpaquePointer') has no member 'name' And I've looked everywhere but I can't find a solution. Does ...
Luis's user avatar
  • 61
2 votes
3 answers
89 views

How to use struct declare

I want to hide the struct define, so I define struct in the source file, like this : //a.c #include "a.h" struct a_s { int a; int b; }; int func(a_t *a) { printf("%d\n", ...
sundq's user avatar
  • 763
1 vote
1 answer
284 views

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 <stdio.h> #include <stdlib.h&...
thepufferfish's user avatar
2 votes
1 answer
815 views

When to use Pimpl pattern over Nested class in C++ or vice versa?

In C++ ,most of developers are using pimpl idiom or opaque pointers to hide the private data/implementation from the public API, for an example : => first case ## Opaque Pointer and PIMPL idiom ## //...
Buddhika Chaturanga's user avatar
0 votes
0 answers
96 views

How to wrapping in C a C++ function with vector<struct> output argument? [duplicate]

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 ...
crossmax's user avatar
  • 342
0 votes
1 answer
38 views

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 ...
St.Antario's user avatar
  • 27.3k
0 votes
2 answers
589 views

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. ...
Maraz's user avatar
  • 82
3 votes
1 answer
341 views

Putting opaque struct definition into a separate header file

I'm designing a library with a public interface containing opaque struct declaration: lib_public.h: typedef struct lib_struct lib_struct; void foo(lib_struct *ptr); void bar(lib_struct *ptr); The ...
St.Antario's user avatar
  • 27.3k
1 vote
1 answer
76 views

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 ...
St.Antario's user avatar
  • 27.3k
3 votes
2 answers
80 views

In this case, how to modularize program as well as achieving information hiding?

I created two classes "DEVICE_s" and "DEVICE_SET_s" as following: Device_Manager.h typedef struct DEVICE_s DEVICE_s; typedef struct DEVICE_SET_s DEVICE_SET_s; Device_Manager.c struct DEVICE_s { ...
Andy Lin's user avatar
  • 447
0 votes
2 answers
466 views

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?
thepufferfish's user avatar
0 votes
0 answers
249 views

SQL syntax error throwing near "CLUSTERED": syntax error [duplicate]

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: ....
Amit's user avatar
  • 645
3 votes
1 answer
484 views

How to call C functions involving opaque pointers from Fortran 2003 correctly?

I'm learning Fortran 2003. As a training task, I'm trying to make calls from Fortran 2003 to a C library that uses opaque pointers: struct foobar_s; typedef struct foobar_s *foobar; foobar foo_create(...
aitap's user avatar
  • 335
1 vote
3 answers
6k views

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". ...
palnic's user avatar
  • 436
4 votes
1 answer
845 views

Dealing with opaque pointers in pybind11

I am moving a Python module written in C++ from Boost.Python to Pybind11. My C++ code relies on a C library that has opaque pointers. With Boost.Python, I used the documentation here to deal with ...
sunmat's user avatar
  • 7,228
3 votes
1 answer
426 views

Using an opaque pointer to a non struct type

In my C programming, I use opaque-pointers to struct as a way to enforce abstraction and encapsulation of my code, in that manner : interface_header.h: typedef struct s_mytype t_mytype; ...
VannTen's user avatar
  • 461
0 votes
1 answer
589 views

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 ...
David Sanford's user avatar
0 votes
2 answers
450 views

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; ...
Schafwolle's user avatar
2 votes
1 answer
560 views

Initialize an AudioConverterRef Swift 3.0

var audioConverter : AudioConverterRef = nil audioConverter = AudioConverterRef.init() So basically I have the code above found from this StackOverflow answer that is using a previous version of ...
Chan Jing Hong's user avatar
3 votes
1 answer
1k views

ABAddressBook fromOpaque(_:) in Swift 3

So I've just updated to Xcode 8 and converted my Swift 2.3 code to Swift 3, and I have an error in this line of code that wasn't in Swift 2.3: func populateFrom(_ addressBook:ABAddressBook) { let ...
Charlie Pico's user avatar
  • 2,036
3 votes
1 answer
335 views

Opaque structures with multiple definitions

I am considering realizing a simple interface pattern in the C language. A key characteristic is that it would provide multiple definitions for an opaque sturcture supplied by the interface's public ...
Jubatian's user avatar
  • 2,191
6 votes
3 answers
1k views

Opaque struct without definition

I am designing an iterator interface for my hashmap data structure. The current design looks like this: // map.h typedef struct map_iterator map_iterator; // map.c struct map_iterator { // ...
Andrew Sun's user avatar
  • 4,231
2 votes
2 answers
479 views

Opaque pointer to struct with template members

Suppose I'm building a linked list (the real data structure is completely different, but a linked list suffices for the question) whose nodes look like template <typename T> struct node { ...
gspr's user avatar
  • 11.3k
10 votes
1 answer
3k views

'init()' is deprecated: init() will be removed in Swift 3. Use `nil`

I was using this code. var audioUnit:AudioUnit = AudioUnit() But in Xcode 7.3 (Swift 2.2) I am getting this warning. Any idea why? And how can I get rid of that? N.B. Is I use nil then my program ...
user avatar
4 votes
1 answer
140 views

Typesafe StablePtrs

I spent a lot of time encoding invariants in my data types and now I am working on exposing my library to C via the FFI. Rather than marshal data structures across the language barrier I simply use ...
Brandon Ogle's user avatar
0 votes
1 answer
334 views

How do I declare an opaque anonymous structure defined in third-party?

I am working on a third-party module wrapper. I hope my main header file does not have any third-party related header files. Every parameter type and return type are opaque by only declaring it. But ...
Chen OT's user avatar
  • 3,594
5 votes
1 answer
3k views

How do I create a module in MISRAC:2012 that follows Dir 4.12 and 4.8?

This question relates to coding in ISO C99 following the MISRAC:2012 guidelines. I am looking for guidance on Dir 4.8 “If a pointer to a structure or union is never dereferenced within a translation ...
crisls's user avatar
  • 53
6 votes
2 answers
3k views

unique_ptr to an opaque struct? (C++)

A library defines an opaque data type: struct OpaqueStruct; and the client code has to obtain and release an OpaqueStruct*. I have access to the library source. Unfortunately, neither shared_ptr ...
18446744073709551615's user avatar
0 votes
1 answer
1k views

Is it possible to exclude template member variables by conditions on template arguments?

I am currently writing a class which should specialize depending on a template argument. I am now wondering whether it is possible to leave out certain member variables for specific specializations ...
Blackclaws's user avatar
0 votes
1 answer
59 views

Core Graphics Opaque type, what are they and how?

I am learning Core Graphics and particularly learning about the CGContextRef. My question is about the syntax and implementation details (if they are knowable) of opaque data types. I understand ...
Alexander Bollbach's user avatar