I have the following line of code in my program -
typedef GROUP ACE_SOCK_GROUP;
That gives the following warnings and errors -
Warning 181 warning C4091: 'typedef ' : ignored on left of 'int' when no variable is declared
Error 182 error C2143: syntax error : missing ';' before 'constant'
Error 183 error C2059: syntax error : 'constant'
The definition of GROUP is given in another file that is included by my program as -
typedef unsigned int GROUP;
What does 'constant' here refer to?
What could be causing the error?
What is the warning indicating
I am using Visual Studio 2008 and found the definition of GROUP using the F12 function
The code is correct.
You're forgetting to include the file where GROUP is defined.
You can try a simple test to confirm this is the issue:
typedef unsigned int GROUP;
typedef GROUP ACE_SOCK_GROUP;
If this compiles, and it will, that means that the previous definition of GROUP is not seen. You need to include the file with the definition before defining ACE_SOCK_GROUP.
Related
I am porting some C++ code to Android. One of the source files includes a webrtc header file that causes error during compilation. I have reduced the problem to this simple code:
template <class T, int n>
struct DefaultDeleter<T[n]> {
// Never allow someone to declare something like scoped_ptr<int[10]>.
static_assert(sizeof(T) == -1, "do not use array with size as type");
};
The error I get is:
[armeabi-v7a] Compile++ thumb: dummyclient <= dummy.cpp
dummy.cpp:7:3: warning: identifier 'static_assert' will become a keyword in C++0x [-Wc++0x-compat]
dummy.cpp:5:8: error: 'DefaultDeleter' is not a template
dummy.cpp:7:17: error: expected identifier before 'sizeof'
dummy.cpp:7:17: error: expected ',' or '...' before 'sizeof'
dummy.cpp:7:70: error: ISO C++ forbids declaration of 'static_assert' with no type [-fpermissive]
The same code compiles fine on Windows and Linux. Is there some compiler settings that are required for Android? Regards.
You need to pass the CPPFLAG -std=c++11.
Hello I am trying to use msxml and I am getting a linker (VS 2012) error and can't figure out why.
My class file has the following header declaration:
#include <MsXml6.h>
class Foo
{
....
private:
static IXMLDOMDocument* document;
};
I then reference the document with the following (which gives the link error):
CoCreateInstance(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (void**)&document);
I have the project setup to link against msxml6.lib. The logs are as follows:
Searching C:\Program Files (x86)\Windows Kits\8.0\lib\win8\um\x64\msxml6.lib:
1> Found IID_IXMLDOMDocument
1> Referenced in Foo.obj
1> Loaded msxml6.lib(msxml6_i.obj)
...
1>Foo.obj : error LNK2001: unresolved external symbol "private: static struct IXMLDOMDocument * Foo::document" (?document#Foo##0PEAUIXMLDOMDocument##EA)
1>Some.exe : fatal error LNK1120: 1 unresolved externals
Is there something important I am missing? Let me know if you need more info.
Thanks!
I found the problem, I forgot to declare the document variable in the source file.
I'm using the method dentry_path in my kernel module, compilation work fine but when loading the kernel module I go the error message:
Error: could not insert module my_mod.ko: Unknown symbol in module
And in /var/log/kern.log
May 8 19:45:10 zUbuntu kernel: [ 1173.105984] my_mod: Unknown symbol dentry_path (err 0)
This method is declared like the following:
extern char *dentry_path(struct dentry *, char *, int);
Could you please explain me why I can't link my module using this method ?
I think you need to use dentry_path_raw instead of dentry_path, cause dentry_path isn't exported. Also, dentry_path_raw is the safer version between these two, it's protected with a writelock.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My Visual Studio 2010 does not allow my file to be compiled when I use the semi-colon characters (";")/ It says there is an error.
But not all of the semi-colons, just one of them.
1>------ Build started: Project: waynekwa, Configuration: Debug Win32 ------
1>Build started 7/11/2012 11:58:46 PM.
1>InitializeBuildStatus:
1> Touching "Debug\waynekwa.unsuccessfulbuild".
1>ClCompile:
1> waynekwa.cpp
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(6): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(11): error C2059: syntax error : ';'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(11): error C2143: syntax error : missing ';' before ')'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(11): error C2143: syntax error : missing ';' before ')'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(12): error C2143: syntax error : missing ';' before '{'
1>c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(27): fatal error C1075: end of file found before the left brace '{' at
'c:\users\asus\documents\visual studio 2010\projects\waynekwa\waynekwa\waynekwa.cpp(3)' was matched
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.14
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The code:
#include<stdio.h>
int main(void) {
int num,x,y=0;
printf("enter range:");
scanf("%i",&num);
for(x=1;x<=;x++) {
if(num%x==0) {
y++;
}
if(y==2) {
printf("it is prime number.\n");
} else {
printf("it is not prime number.\n");
}
return 0;
}
It looks like you forgot a closing bracket for your for loop. You need one between the else of the second if and your return. This is the cause of the second actual error, fatal error C1075: end of file found before the left brace '{'.
Also, for (x = 1; x <= ; x++) is not a valid for loop. The second part x <= ; is missing a value to compare against. For example, x <= 10;. That's where the syntax error error C2059: syntax error : ';' is coming from. The other complaints about semicolons are due to this error.
Edit:
Also, your assignment int num,x,y=0; is difficult to understand. I recommend you clean it up, either by putting on multiple lines or by chain assigning.
Given the information you have given us, you probably need to add or remove one or more ; then add a } somewhere after line 3. But you also may not need to do these things.
The first thing that comes to mind is the line:
for(x=1;x<=;x++) {
you have a x<= just sitting there alone, you have to put a value there.
I'm guessing that you meant:
for(x=1; x<=num; x++) {
But other than that, no other syntax errors are jumping out at me.
I want to use atomic API, and I include . I don't know how to use it! Thank you!
I have it in /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/atomic.h.
I also add -I/usr/src/linux-headers-2.6.28-11/arch/x86/include/ and -I/usr/src/linux-headers-2.6.28-11/include.
Some other errors is produced because of -DCONFIG_X86_32 and -D__KERNEL__ macro undefined.
Then I define the two macros,
some errors occurred:
/usr/src/linux-headers-2.6.28-11/include/linux/cpumask.h:600:37: error: "and" may not appear in macro parameter list
/usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/processor.h:159:1: warning: "cache_line_size" redefined
/usr/src/linux-headers-2.6.28-11/include/linux/cache.h:64:1: warning: this is the location of the previous definition
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected identifier before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected `}' before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected unqualified-id before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:18: error: expected declaration before ‘}’ token
My system is ubuntu 9.04 running on Virtualbox3.0.
If you know where the file is on your HD, then you say gcc mySource.c -I/path/to/atomic
note that this assumes you include "atomic" directly. and not "some/path/atmomic.h"