Protocol Buffers with dll programing c++ [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm trying to write a plugin for rFactor in C++ and I'd like to use Protocol Buffers for serialize all the data and send it with sockets. I tried protobuf succesfuly with other projects I developed but I get some error with this example.
Error C2440 'initializing': Can't convert 'void *(__cdecl *)(size_t)'
to 'void *(__fastcall *)(size_t)' InternalsPlugin
c:..\include\google\protobuf\arena.h 150
I don't understand why is happening because it worked properly with other projects...I'm lost...any ideas?

windows has different calling conventions. When calling a function one needs to specify the calling convention used. In your case your function pointer is set up to use the __cdecl calling convention (the default in C or C++ on windows).
To solve your problem, you will probably need to include an explicit calling convention declaration in your function pointer declaration.
Without more details, I cannot provide better help.

Related

namespace "Detours" has no member "uint8_t" [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have been trying to create a dll program for a game called csgo. But my main problem is that it wont work until I have fixed this bug.
<namespace "Detours" has no member "uint8_t">
It happend right here:
oEndScene = (EndScene)Detours::X86::DetourFunction((Detours::uint8_t*)d3d9Device[42], (Detours::uint8_t*)hkEndScene);
Detour namespace doesn't define a uint8_t type (since it is from Microsoft, I think they'll name it something like USHORT). It is available in the STL in the global namespace. So to resolve this, dont specify where (which namespace) the type comes from,
oEndScene = (EndScene)Detours::X86::DetourFunction((uint8_t*)d3d9Device[42], (uint8_t*)hkEndScene);
And make sure to include stdint.h or inttypes.h header file to get the type.
Additional: Use reinterpret_cast<uint8_t*>() instead of (uint8_t*).
Add
#include <cstdint>
then remove the "Detours" part of "Detours::uint8_t". Just use the regular uint8_t, I don't think you need the wrapper.

Declaring non-intrinsic types with () after variable name has different behavior than without. i.e. std::map<int,char>x(); - what's with that? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a member variable declaration of:
std::map<int,char>x;
in my header file.
It compiles, but when I run my binary I get a segfault in the initialization of the class, before I even get into the constructor.
If I change the declaration to std::map<int,char>x(); -i.e. I just added a () after the variable name - it works fine, no segfault.
I can't give any more specific example than the above, but if anyone has experience with this I'd be interested to know what's going on.
Compiler version is gcc version 4.8.5
target is x86_64-redhat-linux
I realize this is fairly nonspecific but I'm only looking for a general answer.
Thanks.
This is the most vexing parse, as coined by Scott Meyers.
In the standard, look up Ambiguity resolution [stmt.ambig].
As for the segfault, you will need to provide the code (see MRE) to help you with that.

why does scanf_s cause Compiler Error on OnlineJudge? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I use scanf_s to input data.
It causes compiler error on OnlineJudge, while scanf can pass the test.
I've included cstdio.
Is scanf_s included in other STLs?
As Govind Parmar stated in his comment, scanf_s is a Microsoft extension. OnlineJudge uses GNU C++ compilers, and thus, using Microsoft extensions will not work.
Helpful note: if you'd like to test your code on a standard compiler before submitting, there are several available online, such as ideone.

Conflicting types for 'memchr' [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm currently trying to modify a library (ASN.1 Compiler), written in C, so I can compile and use it in C++ Builder (XE6).
Doing that, I've encountered the error "Conflicting types for 'memchr'" (in cstring).
After some research, it seems that this problem comes from the fact that C and C++ code are mixed. However, I can't use the solutions suggested by the article in which I read that since they are related to the GCC compiler, when I'm using C++ Builder and its compilers.
What can be the solutions to solve this error?
Thank you
You probably mix including cstring and string.h. Do not do this.
The former declares:
void * memchr(void *, int, size_t);
the latter does
void * memchr(const void *, int, size_t);
Those are not of the same type.

size_t redefined in calcstar [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I need to use calcstar that is math expression evaluator...
I just simply include calcstar.h file and it include everything else
#include "calcstar.h"
but when I try to compile my code i get this error:
size_t redefined
This error appears inside calcstar's own files...but the point is that this library is published online so I assume it is tested and doesn't have a bug...
What is the problem? Am I doing something wrong?
I really need a mathematical expression evaluator for my project.
CalcStar, assuming you got it from here, was apparently developed using Visual Studio 2008 (the download file name is CalcStarApp_VS2008_03202014.zip.).
One of the quirks of Visual Studio is that it allows redefinition of typedefs. Other compilers (like the one you appear to be using) do not.
You'll need to modify code appropriately.