89 questions
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 ...
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....
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 ...
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 ...
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 ...
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 ...
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:
...
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.
...
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) ...
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 ...
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(...
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 ...
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 ...
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 ...
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 ...
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 ...
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;
...
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 ...
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 ...
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 ...
-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 ...
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", ...
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&...
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 ##
//...
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 ...
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 ...
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. ...
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 ...
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 ...
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
{
...
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?
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: ....
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(...
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". ...
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 ...
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;
...
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 ...
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; ...
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 ...
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 ...
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 ...
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
{
// ...
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
{
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...