Hi I am trying to write a routine in VC ++ was originally compiled in GCC. When I make the following definition:
typedef float v4sf __attribute__ (vector_size(16));
The compiler throws me the following error:
C2146: syntax error: missing ';' before identifier '__attribute__'
As I can replace this line?
Thank you!
Related
I am programming with /std:c++latest in VS2019 v16.10.0. Everything compiled fine with previous version of VS2019. Now I get many errors in header related to _DEPRECATE_TR1_NAMESPACE.
How can I compile around this deprecation?
An example of an error follows:
error C2146: syntax error: missing ';' before identifier 'subtract_with_carry_01'
where the code referenced is:
template <class _Ty, size_t _Wx, size_t _Sx, size_t _Rx>
class _DEPRECATE_TR1_NAMESPACE subtract_with_carry_01
: public _Swc_base<_Ty, _Sx, _Rx, _Swc_01_traits<_Ty, _Wx, _Rx>> { // subtract_with_carry_01 generator
The workaround I found was to
#define _HAS_TR1_NAMESPACE 0
before all header files.
Or to add _HAS_TR1_NAMESPACE=0; in the preprocessor definitions...
This allows me to use latest C++ language!!
doing some C++/CLI coding again, and running into issues. Working in VS2008 if it matters at all.
Here's a mock up of what I am trying to do. In reality ClassA is the GUI and ClassB is the backend that the gui needs to interact with. I am trying to give them access to eachother by passing them to eachother, but I cannot properly get them in scope to create a reference to the other one.
http://pastie.org/private/tnyxazwtyzv3luddz7seq
If you have any input I would greatly appreciate it. I have spent much of today looking online and this solution I currently have has gotten me quite close but I am still getting compile errors. Here's what I am now getting:
Error 1 error C2653: 'NameSpaceB' : is not a class or namespace name c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 2 error C2143: syntax error : missing ';' before '^' c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 5 error C2653: 'NameSpaceA' : is not a class or namespace name c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 6 error C2143: syntax error : missing ';' before '^' c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
This is the same error I am getting in my actual project, so I know it's something funky with my configuration.
/*B.h File Contents*/
#ifndef CLASSB_H
#define CLASSB_H
#include "A.h"
Remove the #include "A.h" part and you're golden. Since class B doesn't use A (at least in the definition), there's no need for the include.
I have a project that was build in vc6,Now I have to convert it into vc9.
In the code there is line
CMapStringToOb cLogPathMap;
ofstream tlogFile;
But when I build the project the following error occur.
error C2146: syntax error : missing ';' before identifier 'tlogFile'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
When I go to definition of ofstream the file iosfwd is opened where ofstream defined as
typedef basic_ofstream<char, char_traits<char> > ofstream;
The following microsoft suggests to include fstream:
http://msdn.microsoft.com/en-us/library/e9cabcax%28v=vs.90%29.aspx
So put the following line in your header includes for that c++ file:
#include <fstream>
In my project, I include pfring.h, but compile error: some functions in net/if.h and linux/if.h are redefinition. I found that the pfring.h include linux/if.h
So, I test a program, my test code:
#include <linux/if.h>
#include <net/if.h>
int main(void) {
return 0;
}
It expected compile error.
So, what's wrong with linux/if.h and net/if.h ?
Can not I include them at once?
error message:
In file included from test.c:1:0:
/usr/include/linux/if.h:178:19: error: field 'ifru_addr' has incomplete type
/usr/include/linux/if.h:179:19: error: field 'ifru_dstaddr' has incomplete type
/usr/include/linux/if.h:180:19: error: field 'ifru_broadaddr' has incomplete type
/usr/include/linux/if.h:181:19: error: field 'ifru_netmask' has incomplete type
/usr/include/linux/if.h:182:20: error: field 'ifru_hwaddr' has incomplete type
In file included from test.c:2:0:
/usr/include/net/if.h:45:5: error: expected identifier before numeric constant
/usr/include/net/if.h:112:8: error: redefinition of 'struct ifmap'
/usr/include/linux/if.h:136:8: note: originally defined here
/usr/include/net/if.h:127:8: error: redefinition of 'struct ifreq'
/usr/include/linux/if.h:170:8: note: originally defined here
/usr/include/net/if.h:177:8: error: redefinition of 'struct ifconf'
/usr/include/linux/if.h:219:8: note: originally defined here
For me (on Ubuntu 12.04 x64) the following include solved the problem:
#include <sys/socket.h> // <-- This one
#include <linux/if.h>
#include <linux/if_tun.h>
This problem has been resolved, add the compile flag -DHAVE_PCAP is fix. ;-)
At first let us talk about the source: The header files are from different Packages as you can see asking dpkg.
$ dpkg -S /usr/include/linux/if.h
linux-libc-dev:i386: /usr/include/linux/if.h
$ dpkg -S /usr/include/net/if.h
libc6-dev:i386: /usr/include/net/if.h
linux-libc-dev is part of linux kernel packages while libc6-dev is part of the libc6 (Standard C library in version 6).
It seams like they are interchangeable so you should only use one (not 100% sure about this). If you pick linux/if.h, you may depend on Kernel versions with your compiled binary.
All new Library versions I have in mind stick with net/if.h instead of the linux one - so you should do the same.
If you are using one of the interface state flags (eg: IFF_UP, etc.), you need one more header than mentioned in other posts.
#include <sys/types.h> // <==
#include <sys/socket.h>
#include <linux/if.h>
I am getting these errors when i compile sim_routing.cc program by this command:
../../bin/cxx sim_routing.cc
g++ -Wall -o sim_routing sim_routing.cxx
The following errors are shown:
../../common/priority_q.h : In member function 'bool guardedQueue<ITEM>::Validate(Const char*);
error : there are no argument to 'strcat' that depend on template parameter so a declaration of 'strcat' must be avaible.
error : <if you use -fpermissive g++ will accept your code but allowing use of undeclared name is deprecated>
When i tried to change the commom/priority_q.h file, it shows it is read only file, so changes cannot be made.
How can these errors be corrected?
Not sure about this, but you could possibly try to include
#include <cstring>
before you include that priority_q.h file in your code. That should bring strcat's declaration in scope before that template is processed.