-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Not working for classes containing "_declspec(dllimport)" in their declaration #1108
Comments
Hello, Assuming your code is not too different from what you reported, my first guess would be that the second argument of void to_json(json&, Person const&){} Did you put the const reference when trying with a different class? That would explain why it worked. |
Nope using a const reference also does not make a difference. When I tried with my own class as compared to the class coming from the 3rd party SDK, I declared the void to_json(json& j, Person* o); No other definition was working for me. However, when I used the same logic for the class coming from the 3rd party SDK, it started throwing the errors that I mentioned in my previous comment |
Is the type from the third party in a namespace? |
Oh, wait I did miss the part about third party type... Please take a look here, that should help solve your problem. |
@theodelrieu I am not sure if the specified section helps me. I know for a fact that the 3rd party library does not contain @gregmarr Yes! |
namespaces |
I know. But the 3rd party library does not use any custom namespace. Instead, I am consuming it as a DLL that exposes its symbols using the __declspec(dllimport) specifier. |
FYI, namespaces and dllexport are not mutually exclusive. I'm confused. I asked if it uses a namespace, and you said yes to me, but then you said one message later that it doesn't use a namespace. That answer is VERY important. If the type is in a namespace, then the |
@gregmarr Sorry for the confusion but the third party type is not in a namespace. I read the documentation and was aware of the fact that the Also, I am not sure as to how Please let me know if you need any other details. I am more than willing to help in this matter and I'll make sure I do my due diligence. |
This code can't be correct, as you are assigning a |
Just to make sure that we're looking at the right thing, can you post the exact test code and error message if possible? |
Ok give me some time. I'll post similar/simplified code to demonstrate the workflow and the errors that i am encountering. I would have to make a custom DLL project that exposes the functions in a similar manner, as the third party library that I am talking about has been developed inhouse. So, I can't really post the exact code here. |
Hi guys, I was able to get this work while I was building the sample application. Basically I was maintaining the Maybe we can cover this via documentation and be explicit about it so that no one else runs into this issue? Anyways, thanks a lot for your prompt responses. Now I will go on and use this awesome library. |
Alright, I shall add a note to the documentation. |
Hi,
I have a 3rd party SDK included in my project that has class declarations like below -
Let's assume the class name as Person (simplified the code for reporting purposes) -
I am trying to serialize the class using the below
to_json
function as mentioned in the documentation -However even though everything is syntactically correct, I am getting the below errors on building my project -
could not find to_json() method in T's namespace
'force_msvc_stacktrace': is not a member of 'Person'
'force_msvc_stacktrace': undeclared identifier
forcing MSVC stacktrace to show which T we're talking about.
I have also tried creating a simple class without the
_declspec(dllimport)
and that works like a charm.Can someone please help in this regard?
Details:
The text was updated successfully, but these errors were encountered: