Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp.Pointer requires a defined type / Breaks externs #432

Closed
PDeveloper opened this issue Apr 25, 2016 · 6 comments
Closed

cpp.Pointer requires a defined type / Breaks externs #432

PDeveloper opened this issue Apr 25, 2016 · 6 comments
Assignees

Comments

@PDeveloper
Copy link

PDeveloper commented Apr 25, 2016

Revision: 4a6b30a
Date: 13/4/2016 9:06:06 AM

In this revision, this was added:

enum { elementSize = sizeof(T) };

This causes issues when compiling libraries that contain forward declared types, specifically snowkit/linc_sdl#8
Removing that one line allowed me to compile my project. In SDL sources, SDL_Window is defined as typedef struct SDL_Window SDL_Window; in include/SDL_video.h
SDL_Window is given a concrete definition ONLY in internals that shouldn't be used from the public API.

I would argue that requiring the sizeof() of a type breaks pointers, because of cases like the above, which in my view aren't all too uncommon.

@PDeveloper
Copy link
Author

PDeveloper commented Apr 25, 2016

Currently exploring alternatives to using ::cpp::Pointer in snowkit/linc_sdl, perhaps this would be a better solution!

@PDeveloper
Copy link
Author

Changing to use a cpp.RawPointer fixes things! Sorry for the disturbance! (Hadn't noticed cpp.RawPointer before :) )

@Simn
Copy link
Member

Simn commented Apr 25, 2016

I'm still a bit curious what exactly changed here and what the difference between Pointer and RawPointer is. That might be worth documenting?

@Simn Simn reopened this Apr 25, 2016
@PDeveloper
Copy link
Author

As far as I know, a RawPointer is a straight up C++ pointer Type* type_p;

The change here is that SDL_Window wasn't a complete type from the headers, and ::cpp::Pointer<T> does a sizeof(T), causing it to fail (expectedly).

@hughsando
Copy link
Member

I think I can remove the sizeof from the header. You are right that it is an unnecessary restriction.
The difference between raw and cpp.Pointer is that the latter wraps the pointer in a struct to allow it to be passed Dynamically.

@PDeveloper
Copy link
Author

Yep, changing to a RawPointer causes more issues relating to Dynamic!

Should I pull request or can you do a small commit for this? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants