Newbie chrome-plugin developer needs help getting started with NPAPI - c++

Although only having done a very little in C++ before I'm trying to compile the following chrome plugin so that I can see how it works and use that as a starting point to develop something similar: http://code.google.com/p/minimizetotray/source/browse/trunk/?r=17#trunk%2FDLL
So far I have taken the following steps: downloaded the source, opened it in MS Visual Studio Pro 2008, and obtained a few of SDKs and headerfiles it was asking for including the latest version of the NPAPI headers: http://npapi-sdk.googlecode.com/svn/trunk/headers/
Now I get the following errors when I try to compile and have no idea how to sort this.
Compiling...
JSMethods.cpp
c:\documents and settings\dell customer\desktop\dll\jsmethods.cpp(92) : error C2039: 'UTF8length' : is not a member of '_NPString'
c:\program files\microsoft visual studio 9.0\vc\include\plugin\npruntime.h(85) : see declaration of '_NPString'
c:\documents and settings\dell customer\desktop\dll\jsmethods.cpp(101) : error C2039: 'UTF8characters' : is not a member of '_NPString'
c:\program files\microsoft visual studio 9.0\vc\include\plugin\npruntime.h(85) : see declaration of '_NPString'
Etc...
Apart from those two errors it all seems dandy, its not asking for missing includes or anything. Any help appreciated!

Unless I'm mistaken on the latest SDK the _NPString struct is defined as...
typedef char NPUTF8;
typedef struct _NPString {
const NPUTF8 *UTF8Characters;
uint32_t UTF8Length;
} NPString;
And in your code you are calling UTF8length instead of UTF8Length (uppercase L).

Related

Compiling Amensia The Dark Descent open source code in Visual Studio 2019 gives error regarding xutility.h

https://github.com/FrictionalGames/AmnesiaTheDarkDescent
So Frictional Games released the open source for Amnesia The Dark Descent. They also included a visual studio solution. So I download and open up. The compilation goes good except an error where a certain source file cannot compile due to an illegal expression. The error message goes:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xutility(1544,5): error C2056: illegal expression (compiling source file sources\gui\GuiSet.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xutility(1544,39): error C2056: illegal expression (compiling source file sources\gui\GuiSet.cpp)
Now, I haven't touched any of the code so the error is most likely an issue with the release in relation to my current Visual Studio version. Is there a way for me to resolve this. If you want to help please download the source code and try yourself.
Just because I just randomly tried to do the same as well, I can tell you this specific problem is because the definition of cGuiRenderObjectCompare::operator() is missing the const keyword. You need to fix bool operator()(const cGuiRenderObject& aObjectA, const cGuiRenderObject& aObjectB); into bool operator()(const cGuiRenderObject& aObjectA, const cGuiRenderObject& aObjectB) const;
You need a similar fix in both GuiSet.h and GuiSet.cpp.

Visual Studio 2013 crashes for non-static data member initialization

i wanna compile Trinitycore with visual studio 2013(x86 & x64 both tested) on windows 10
i get this error and i test every solutions such as:
1.change /Zm on Additional Options from /Zm500 to /Zm2000(Maximum)
2.disable precompiled headers
3.disable Optimization
4.re-install Visual Studio
5.re-install windows 10
visual studio error description:
Error 1 error C1001: An internal error has occurred in the compiler. \TrinityCore-3.3.5\src\server\game\Server\WorldSocket.cpp 256 1 game
Error 2 error C1060: compiler is out of heap space c\src\server\game\c1xx game
Error 3 error D8040: error creating or communicating with child process c\src\server\game\cl game
event log:
Faulting application name: CL.exe, version: 18.0.21005.1, time stamp: 0x524faabf
Faulting module name: c1xx.dll, version: 18.0.21005.1, time stamp: 0x524faa90
Exception code: 0xc0000005
Fault offset: 0x0025236e
Faulting process id: 0x1948
Faulting application start time: 0x01d19f24d391755f
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe
Faulting module path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\c1xx.dll
Report Id: d98e09ae-0b18-11e6-b361-1008b14a12cc
Faulting package full name:
Faulting package-relative application ID:
vs output errors:
TrinityCore-3.3.5\src\server\game\Server\WorldSocket.cpp(256): fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\convert.cpp', line 9608)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
1> Opcodes.cpp
1>c1xx : fatal error C1060: compiler is out of heap space
1> An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1325)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
1>cl : Command line error D8040: error creating or communicating with child process
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
event log attached file:
Version=1
EventType=APPCRASH
EventTime=131060826745545591
ReportType=2
Consent=1
UploadTime=131060826747020586
ReportIdentifier=e3cb3d99-0b13-11e6-b361-1008b14a12cc
IntegratorReportIdentifier=e3cb3d98-0b13-11e6-b361-1008b14a12cc
WOW64=1
Response.BucketId=d11da6a9b6e3e8a8c8d50161959694bb
Response.BucketTable=1
Response.LegacyBucketId=-389226431
Response.type=4
Sig[0].Name=Application Name
Sig[0].Value=CL.exe
Sig[1].Name=Application Version
Sig[1].Value=18.0.21005.1
Sig[2].Name=Application Timestamp
Sig[2].Value=524faabf
Sig[3].Name=Fault Module Name
Sig[3].Value=c1xx.dll
Sig[4].Name=Fault Module Version
Sig[4].Value=18.0.21005.1
Sig[5].Name=Fault Module Timestamp
Sig[5].Value=524faa90
Sig[6].Name=Exception Code
Sig[6].Value=c0000005
Sig[7].Name=Exception Offset
Sig[7].Value=0025236e
DynamicSig[1].Name=OS Version
DynamicSig[1].Value=10.0.10586.2.0.0.256.48
DynamicSig[2].Name=Locale ID
DynamicSig[2].Value=1033
UI[2]=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe
UI[3]=Microsoft (R) C//C++ Optimizing Compiler has stopped working
UI[4]=Windows can check online for a solution to the problem.
UI[5]=Check online for a solution and close the program
UI[6]=Check online for a solution later and close the program
UI[7]=Close the program
LoadedModule[0]=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe
LoadedModule[1]=C:\Windows\SYSTEM32\ntdll.dll
LoadedModule[2]=C:\Windows\SYSTEM32\KERNEL32.DLL
LoadedModule[3]=C:\Windows\SYSTEM32\KERNELBASE.dll
LoadedModule[4]=C:\Program Files (x86)\MSBuild\12.0\bin\FileTracker.dll
LoadedModule[5]=C:\Windows\SYSTEM32\ADVAPI32.dll
LoadedModule[6]=C:\Windows\SYSTEM32\msvcrt.dll
LoadedModule[7]=C:\Windows\SYSTEM32\sechost.dll
LoadedModule[8]=C:\Windows\SYSTEM32\RPCRT4.dll
LoadedModule[9]=C:\Windows\SYSTEM32\SspiCli.dll
LoadedModule[10]=C:\Windows\SYSTEM32\CRYPTBASE.dll
LoadedModule[11]=C:\Windows\SYSTEM32\bcryptPrimitives.dll
LoadedModule[12]=C:\Windows\SYSTEM32\ole32.dll
LoadedModule[13]=C:\Windows\SYSTEM32\combase.dll
LoadedModule[14]=C:\Windows\SYSTEM32\GDI32.dll
LoadedModule[15]=C:\Windows\SYSTEM32\USER32.dll
LoadedModule[16]=C:\Windows\SYSTEM32\MSVCR120.dll
LoadedModule[17]=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\mspdb120.dll
LoadedModule[18]=C:\Windows\SYSTEM32\VERSION.dll
LoadedModule[19]=C:\Windows\SYSTEM32\IMM32.DLL
LoadedModule[20]=C:\Windows\SYSTEM32\CRYPTSP.dll
LoadedModule[21]=C:\Windows\system32\rsaenh.dll
LoadedModule[22]=C:\Windows\SYSTEM32\bcrypt.dll
LoadedModule[23]=C:\Windows\SYSTEM32\MSVCP120.dll
LoadedModule[24]=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\mspdbcore.dll
LoadedModule[25]=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\c2.dll
LoadedModule[26]=C:\Windows\SYSTEM32\SHLWAPI.dll
LoadedModule[27]=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\c1xx.dll
LoadedModule[28]=C:\Windows\system32\apphelp.dll
State[0].Key=Transport.DoneStage1
State[0].Value=1
FriendlyEventName=Stopped working
ConsentKey=APPCRASH
AppName=Microsoft (R) C//C++ Optimizing Compiler
AppPath=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe
ApplicationIdentity=00000000000000000000000000000000
i really confused because i am compile this project many times with this steps and with this visual studio.
Edit 1:
i create new Win32Project and i put this code on that:
#include "stdafx.h"
# define LENGTH 20
typedef unsigned char uint8_t;
typedef uint8_t uint8;
struct test
{
uint8 intT[LENGTH] = {};
};
and when i compile that i got this error again:
Error 1 error C1001: An internal error has occurred in the compiler. \Projects\Win32Project1\Win32Project1\Win32Project1.cpp 13 1 Win32Project1
An "internal compiler error" (or ICE) is, by definition, a compiler bug. There could well be code in your program that's triggering that bug. Your crash seems to be triggered by the use of a non-static data member initialisation (NSDMI), and Microsoft admits that their support for NSDMIs in Visual Studio 2013 was unreliable at best:
Unfortunately, the code in our compiler (some of it written 30 years ago) for handling initialization suffers from many longstanding architectural limitations. This code was sufficient for C++03-style initialization, but NSDMI, a C++11 feature, caused it to exhibit these limitations as severe bugs.
Given this, you may also wish to try simply upgrading your toolchain.
However, it could also be that your installation is completely broken/corrupted.
Either way, your first task is to reinstall Visual Studio and see whether the problem persists. Perhaps try compiling the project on a different computer.
If that doesn't fix it, you need to produce a minimal testcase and submit it to the developers for review (at MS Connect). Please be sure to come back here and link us to the posted issue so that I can update the answer with any pertinent information from the developers (e.g. version the bug is fixed in).
OK Finally Problem Solved, Only Need Update Visual Studio 2013 to Visual Studio 2013 Update 5.
On Update 5 For Visual Studio 2013 this bug is fixed completely.
Thank you "Lightness Races in Orbit" And "Niall" for answer and helps :)
i am so happy
This is a ICE (an internal compiler error). It is cause by the code around line 256 of the WorldSocket.cpp file.
In that file; the class AuthSession, here uses non-static default member initialisation (NSDMI) with an array (on line 256) that is shown in the error message.
IIRC, VS2013 does not fully support the NSDMI feature. It was added to C++11 but VS2013 had limitations in its implementation of NSDMI.
The uint8 Digest[SHA_DIGEST_LENGTH] = {}; could just be too much for it to compile.

Visual C++ unit testing errors when including required code

I'm new to C++, I have a Visual C++ project in Visual Studio 2008 (stuck with it I'm afraid) and I'm trying to get unit tests to work. I've got my code and I've got my new test project set up but any time I include the header file of the code I want to test, I get 138 compilation errors.
#include "stdafx.h"
//#include "../ProjName/ProjName.h"
using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
namespace TestProjName
{
...various code created by the wizard...
[TestMethod]
void Test1()
{
Assert::AreEqual(0,1);
};
};
My code compiles (and runs) fine until the #include to my ProjName is uncommented. When it is uncommented, I get a lot of errors from the VS libraries along the lines of:
1>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vadefs.h(89) : error C4956: 'va_list *' : this type is not verifiable
,
1>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\crtdefs.h(2027) : error C4956: 'threadlocaleinfostruct *' : this type is not verifiable
and
1>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\wchar.h(235) : error C2337: 'SA_Post' : attribute not found
Has anyone come across this before? Might anyone suggest a (probably simple) thing I'm overlooking?
Found my own solution after a good while googling. My test project used /clr:safe common language runtime support. Switching it to /clr fixed the issue for me.

VS 2012 template errors

I've been using this code to marshal strings in C++/CLI for a while now. Recently I've updated to VS 2012 RC to try it out. I really liked the simple design, but none of my projects containing clix.h could be compiled. It worked great in 2010... What could be the problem? Thank you for your answers!
Here is compiler output:
Warning C4346:
'clix::detail::IsManagedString::Result'dependent name is
not a type.
Error C2988: unrecognizable template declaration/definition
Error C2059: syntax error : '<'
Error C2039: 'Result' : is not a member of '`global namespace''
Error C2143: syntax error : missing ';' before '}'
The code block errors are in:
typename detail::Select<detail::IsManagedString<SourceType>::Result>::Type<
typename detail::StringTypeSelecter<encoding>::Type,
System::String ^>::Result marshalString(SourceType string) {
// Pass on the call to our nifty template routines
return detail::StringMarshaler<
detail::IsManagedString<SourceType>::Result ? detail::CxxFromNet : detail::NetFromCxx
>::marshal<encoding, SourceType>(string);
}
An example, source file:
#include "clix.h"
int main()
{
}
Clix header file can be found on this link.
You could have just posted the issue on my blog, it's not abandoned or anything :)
I happen to have Visual Studio 2012 RC installed and fixed the issue. You can find a new version of the clix header at the location you linked.
Background: it appears Microsofts new compiler is a bit picky regarding typedefs in nested templates whose parent templates are specialized on integer types. In any case, I found a method that works in both Visual C++ 2010 and Visual C++ 2012 RC.

C++ 2010 Express Protobuf Compiling Errors

I am having a lot of trouble compiling protobuf source code(2.4.1) for the .lib and .dlls. I followed google's intructions in the readme, word-for-word, but gtest has major errors. Although, I get the libprotobuf.lib, libprotobuf-lite.lib, and libprotoc.lib, does having gtest fail matter? Also, I can compile libprotobuf into a .dll but for libprotobuf-lite.dll, and libprotoc.dll the build fails with errors.
My question: How can I still use protobuf for programing in msvc++ 2010 express. Is there anyone else that implements it?
Thanks.
EDIT:: some build errors ...
1>------ Build started: Project: libprotobuf, Configuration: Debug Win32 ------
2>------ Build started: Project: gtest, Configuration: Debug Win32 ------
3>------ Build started: Project: libprotobuf-lite, Configuration: Debug Win32 ------
2> gtest.cc
3> zero_copy_stream_impl_lite.cc
1> zero_copy_stream_impl_lite.cc
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(745): error C3855: 'std::tr1::tuple_element': template parameter '_Idx' is incompatible with the declaration
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(757): error C2039: 'type' : is not a member of 'std::tr1::tuple_element'
2> c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(742) : see declaration of 'std::tr1::tuple_element'
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(757): error C2146: syntax error : missing ',' before identifier 'type'
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(757): error C2065: 'type' : undeclared identifier
2>c:\users\null\desktop\protobuf-2.4.1\protobuf-2.4.1\gtest\include\gtest\internal\gtest-tuple.h(761): error C2039: 'type' : is not a member of 'std::tr1::tuple_element'
I had this too. Thanks to jahhaj for the pointer. I tried just changing tuple_element to tuple__element (double underscore) in gtest-tuple.h. It's used 3 times, one of which is in a comment. Everything then compiled fine both in Debug and Release and all the tests ran successfully.
There were a few warnings that came up during the compilation but as far as I could tell they were either deliberate or vagaries of Visual Studio.
Well I can tell you what the problem is, if not the solution. One of the gtest headers is defining a class called std::tr1::tuple_element. MS define a different class with exactly the same name, you can find it in the <utility> header file. I don't see any way to fix this other than to wait for google to do so. It is a problem that has been reported to them.
Alternatively you could download the pre-compiled Windows version
I experienced this problem as well. Since I was using Visual Studio 2010, std::tr1::tuple is actually defined.
Reading a bit in the README file, section Choosing a TR1 Tuple Library, lead me to trying the compiler flag -DGTEST_USE_OWN_TR1_TUPLE=0 or in Visual Studio would simply be GTEST_USE_OWN_TR1_TUPLE=0.
This solved my issue since this tuple is already defined in the TR1 features provided in Visual Studio 2010.