We received this piece of code for an assignment, and after spending a lot of time fixing the problems within, I ended up with a syntax error : identifier 'String'. Everywhere I look on the web, people are using std::string, but this is not what the code is referring to since the function is called from a C# project using a String object.
Here is the declaration :
int findWindow(String ^CaptionText,IntPtr ^%phWnd,
int %left,int %top,int %right,int %bottom);
And I have no idea how to fix that one. There are other errors such as
error C2062: type 'int' unexpected
...
error C2065: 'IntPtr' : undeclared identifier
error C2065: 'String' : undeclared identifier
...
etc.
Any help appreciated.
Should I mention that those errors have nothing to do with the assignment?
use System::String and System::IntPtr or write using namespace System;
Related
It's perhaps the first time I use a do...while loop. I can't figure out what's wrong with it:
const randomLetter
do {
randomLetter = String.fromCharCode(97 + 26 * Math.random() | 0)
} while (state.lettersFound.includes(randomLetter))
At line do { I'm getting some unexpected token syntax error. Why?
The syntax for declaring a constant is:
const Identifier = Initializer
The parser is expecting to see an equals sign = after the identifier (randomLetter), but instead it unexpectedly sees the keyword do.
So, the error message and the error location is correct: the unexpected token is the keyword do and the error occurs at the token do.
Note: depending on the parser, the error message is more or less helpful, e.g. I get this in Node.js 13.1.0 / V8 7.8:
Thrown:
const randomLetter
^^^^^^^^^^^^
SyntaxError: Missing initializer in const declaration
Note: this is not really about do-loops: anything that is not an equals sign = would trigger a similar syntax error.
Note: vue.js cannot possibly have anything to do with this, since it is clearly a syntax / parse error and ECMAScript (like almost all languages and certainly all mainstream languages) does not allow libraries to change the fundamental syntax of the language.
I'm trying out Mono.CSharp's evaluator.
Why does this simple script work:
int i=2,j=3;
(i*j);
whereas this gives an error:
int i=2,j=3;
i*j;
saying "(1,2): error CS0246: The type or namespace name `i' could not be found. Are you
missing a using directive or an assembly reference?"
Mono.CSharp evaluator follows C# standard grammar rules. In your second example you are actually declaring local variable based on C# grammar.
It can be rewritten to this for easier human parsing
int i = 2, j = 3;
i* j;
Compiler parses second line as another variable declaration and tries to resolve "i" as a type before it applies pointer "*" to it.
OK, after migrated to Gecko 2.0 for my XPCOM Component,
I fixed a couple of thg like below:
1. Replacing #include "nsIGenericFactory.h" to #include "mozilla/ModuleUtils.h"
2. Replacing xpcomglue_s.lib to xpcomglue_s_nomozalloc.lib
3. Adding #include "mozilla-config.h" to xpcom-config.h header file
4. And as well as remove a couple of unused header file eg: nsReadableUtils.h, nsEventQueueUtils.h, nsIExtensionManager.h
5. Replacing NS_DEFINE_STATIC_IID_ACCESSOR(IMYPROGRAM_IID) to NS_DEFINE_STATIC_IID_ACCESSOR(IMyProgram, IMYPROGRAM_IID)
Reduced from 200+ errors to 20+ now, below are a few more errors which i have no idea what is that, any expert here encounter problem like below?
error C3254: 'IMyProgram' : class contains explicit override 'kIID' but does not derive from an interface that contains the function declaration
error C2838: 'kIID' : illegal qualified name in member declaration
error C3857: 'IMyProgram::kIID': multiple template parameter lists are not allowed
error C2084: function 'void nsTraceRefcnt::LogAddRef(void *,nsrefcnt,const char *,PRUint32)' already has a body
error C2084: function 'void nsTraceRefcnt::LogRelease(void *,nsrefcnt,const char *)' already has a body
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C2146: syntax error : missing ';' before identifier 'components'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2440: 'initializing' : cannot convert from 'const char [13]' to 'int'
error C2078: too many initializers
error C2448: 'NS_IMPL_NSGETMODULE' : function-style initializer appears to be a function definition
error C2143: syntax error : missing ';' before '__stdcall'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2556: 'int MyProgramRegistration(nsIComponentManager *,nsIFile *,const char *,const char *,const int)' : overloaded function differs only by return type from 'nsresult MyProgramRegistration(nsIComponentManager *,nsIFile *,const char *,const char *,const int)'
error C2371: 'MyProgramRegistration' : redefinition; different basic types
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C3254: 'IMyProgram' : class contains explicit override 'kIID' but does not derive from an interface that contains the function declaration
error C2838: 'kIID' : illegal qualified name in member declaration
error C3857: 'IMyProgram::kIID': multiple template parameter lists are not allowed
At the very least it looks as if you are missing an NS_DECLARE_STATIC_IID_ACCESSOR(IMYPROGRAM_IID) in your interface (xpidl would have generated that for you automatically.) Some of the other errors are a bit harder to figure out without source code, but the chances are that you haven't quite managed to update your module registration code correctly.
I am getting the following error in my VC++ COM project. What is the problem in linking the lib files here?
Error 4 error LNK2019: unresolved external symbol _BVUOpen#8 referenced in function "unsigned int __stdcall AFunc(void *)" (?AFunc##YGIPAX#Z) CBillAcceptor.obj BillAcceptorCOM
Here are the explanation of the LNK2019 error : MSDN.
Look for a problem of definition about BVUOPen symbol ! The problem si inside the method AFunc Maybe, you haven't declare it correctly or haven't link the library or haven't export the symbol...
Probably, you need to link against some external library that contains the object code for the BVUOpen function. The name of that library is not obvious from your error message, but it should be possible to work out from the documentation you are coding from.
This error message had me stumped for a while:
invalid conversion from 'objc_object* to 'int'
The line in question was something like this:
int iResult = [MyUtils utilsMemberFunc:param1,param2];
It doesn't matter what the "to" type is, what is important is that you recognize that this message, in this context, is reporting that the utilsMemberFunc declaration was not found and due to Objective-C's dynamic binding it is assuming it returns an objc_object* rather than the type that utilsMemberFunc was declared to return.
So why isn't it finding the declaration? Because ',' is being used rather than ':' to separate the parameters.