When i include uhd/usb_control.hpp in my main.cpp :
#include <uhd/transport/usb_control.hpp>
/* Some other includes */
int main (void)
{
uhd::transport::usb_control::sptr usbSpeed;
usbSpeed = uhd::transport::usb_control::make(handle, 0);
/* `handle` is a `usb_device_handle::vid_pid_pair_t` */
}
I got error from here:
static sptr make(usb_device_handle::sptr handle, const int interface);
Error:
unexpected token struct. Did you forget a ';'
struct: missing tag name
And another strange error in:
usbSpeed = uhd::transport::usb_control::make(handle, 0);
Error:
Cannot convert argument 2 from int to const int
The only implementation that i find for uhd::transport::usb_control::make is uhd/transport/usb_dummy_impl.cpp which only throw an exception.
Environment information:
Compiler: MS Visual Studio 2017
OS: MS Windows 10
C++ Standard: 17
How to fix those errors ? I only what to detect the USRP usb type. For this i read the uhd source code and i find the uhd/transport/usb_control.hpp, But I have encountered those errors.
maybe the cause of this unexpected behavior is related to your included files and a conflict between some of them, as you mentioned in addition of #include <uhd/transport/usb_control.hpp> you have some other includes. i suggest move this include line upper and lower of other includes and test your code again.
wish my suggest be useful.
Related
I am using GDAL in visual studio 2019 community version,and I used the sample code in the their official site which is down below,the program compiles, runs and outputs fine, but I got a list of errors and warnings, I don't know if I should ignore them or make some change on header files, anyone encounter issues like this before? hope someone could give me some advice, thank you.
sample code:
/*gdal_test*/
#include <iostream>
#include <gdal_priv.h>
#include <cpl_conv.h>
using namespace std;
int main()
{
const char* pszFile;
GDALAllRegister();
pszFile = "E:/190807/mosaic_data/S2_1_170215.tif";
GDALDataset* poDataset = (GDALDataset*)GDALOpen(pszFile, GA_ReadOnly);
GDALRasterBand* poBand = poDataset->GetRasterBand(1);
int xsize = poBand->GetXSize();
int ysize = poBand->GetYSize();
cout << xsize << endl;
cout << ysize << endl;
system("pause");
return 0;
}
error list mainly contains these three main issue:
Error (active) E0065 expected a ';' gdaltest C:\MSVC_Library\GDAL\warmerda\bld\include C:\MSVC_Library\GDAL\warmerda\bld\include\ogr_geometry.h 387
Error (active) E1455 member function declared with 'override' does not override a base class member gdaltest C:\MSVC_Library\GDAL\warmerda\bld\include C:\MSVC_Library\GDAL\warmerda\bld\include\ogr_geometry.h 1139
Warning C26812 The enum type 'CPLErr' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). gdaltest C:\MSVC_Library\GDAL\warmerda\bld\include C:\MSVC_Library\GDAL\warmerda\bld\include\cpl_error.h 244
should I change the syntax in header files? will change it effect something? Or should I just ignore these errors?
You state that your program, "compiles, runs and outputs fine," so, the errors you are seeing are being reported by the "Intellisense" tool in Visual Studio.
To stop displaying these, go to the "Error List" window and select the "Build Only" option:
The C26812 warning message can be disabled as described in my answer to your recent question.
I am working on a service application in c++ builder XE3.
I am getting compiler error for std::string if I add this line:
string a = string("abcd") + "xyz";
Error output is as follows:
[bcc32 Error] string(141): E2285 Could not find a match for 'move<_Ty>(string)'
Full parser context
string(140): decision to instantiate: string std::string + <char,char_traits<char>,allocator<char> >(string &&,const char *)
--- Resetting parser context for instantiation...
svcmain.cpp(21): #include C:\Program Files\Embarcadero\RAD Studio\10.0\include\boost_1_39\boost\tr1\tr1\string
string(20): #include c:\program files\embarcadero\rad studio\10.0\include\../include/dinkumware/string
string(7): namespace std
string(140): parsing: string std::string + <char,char_traits<char>,allocator<char> >(string &&,const char *)
I tried to add #include <utility> just above #include <string> but still getting same error.
Instead, if I split the line into two as follows, it compiles without errors.
string a = string("abcd");
a += "xyz";
OR
string b = string("abcd");
string a = b + "xyz";
Its not practical to use this workaround as I have to use existing code which is getting large no of errors. Same code works without errors in other XE3 project.
Any ideas how to fix this error?
I found the fix in the other project. Setting the "backward compatibility" option to false fixed the error.
You can find the checkbox in - Project options -> C++ compiler -> Compatibility -> General.
This was initially set to true.
I encountered a compiler crash and intellisense false positives with Visual Studio 2015 using C++.
This crashes the compiler when written within a function block:
if();
This is the dialog that is shown when compiling (I am on a German version of Windows):
Even though the compiler crashes, I get error list output:
Error C2059 syntax error: ')'
Warning C4390 ';': empty controlled
statement found; is this the intent?
Error C1903 unable to recover from previous error(s); stopping compilation
This produces squiggles and error annotations in the vertical scrollbar in map mode, but no actual intellisense errors:
#include <vector>
struct S { std::vector<S> Children; };
int main(int argc, char* argv[]) {
S item;
item.Children.push_back(S());
// ^
// Error: no instance of overloaded function
// "std::vector<_Ty, _Alloc>::push_back [with _Ty=S, _Alloc=std::allocator<S>]"
// matches the argument list
// argument types are: (S)
// object type is: std::vector<S, std::allocator<S>>
S& back = item.Children.back();
// ^^^^
// Error: a reference of type "S &" (not const-qualified) cannot be
// initialized with a value of type "S"
return 0;
}
Are those bugs? Are they known? Can you reproduce them?
For the first case: the compiler shouldn't crash but just issue the diagnostic you show. So yes, that's a bug. Which doesn't occur in VS2013 btw. Submit a report for it here
For the second case: it is the same in VS2013 and is due to nesting a vector of S inside S. This and other cases make the error squiggles appear incorrectly, it is actually not that uncommon. But ideally it should not happen so you can submit a bug report for it as well, though it might be something which is going to be labelled 'wontfix' as the compiler team usually focusses on more urgent cases.
I have ran into a problem compiling some template code with Visual Stuido 2010 SP1, cl.exe version 16.0.40219.1
The following code will cause the compiler to access violate:
template<typename T>
class A
{
A(){}
};
template<typename T>
class B : public A<T>
{
using A::A(); // Compiler access violates
// **EDIT**
//using A<T>::A<T>; // Compiler succeeds
//using A<T>::A(); // Compiler reports error
};
int main(int argc, char* argv[])
{
return 0;
}
It generates the following error (in addition to the "cl.exe has stopped working, C0000005 exception):
1>d:\projects\cpptest\cpptest\cpptest.cpp(11): fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1420)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
The code compiles fine (well, that is, it emits a proper error message and doesn't crash the compiler) in Dev-C++ with g++.
main.cpp:11: error: `template<class T> class A' used without template parameters
main.cpp:11: error: expected nested-name-specifier before "A"
main.cpp:11: error: using-declaration for non-member at class scope
main.cpp:11: error: expected `;' before '(' token
main.cpp:11: error: expected unqualified-id before ')' token
make.exe: *** [main.o] Error 1
EDIT
The following, however, compiles fine, without access violation, so it seems this is related to templates:
class A
{
A(){}
};
class B : public A
{
using A::A;
};
int main(int argc, char* argv[])
{
return 0;
}
Do you think this is worth reporting to Microsoft? Can anyone else reproduce this?
Maybe try in Visual Studio 2013 to see if it still occurs?
Since this is reproducible by others on Visual C++ platforms, I have opened a bug report on Microsoft Connect as "answer".
Also, as workaround, the following syntax works:
using A<T>::A<T>;
Update 2013-12-06: Microsoft has confirmed the issue and the issue will be fixed in the Visual Studio 2013 C++ compiler.
I'm currently on vacation far away from my desktop, however I wanted to practice my c++ in particular with openCV, so I brought my laptop along. Given time and family constraints I didn't get everything set up in time with the libraries before flying.
I've set everything up with regards to VS 2010 as I recall doing on my desktop a while ago, but on compiling the test example on the openCV website (http://opencv.willowgarage.com/wiki/VisualC%2B%2B) I receive the following errors:
Error 3 error C2244: 'cv::Matx<_Tp,,>::diag' : unable to match function definition to an existing declaration C:\Program Files\OpenCV2.2\include\opencv2\core\operations.hpp 372
Error 4 error C2244: 'cv::Matx<_Tp,,>::diag' : unable to match function definition to an existing declaration C:\Program Files\OpenCV2.2\include\opencv2\core\operations.hpp 448
which in turn shows me:
template<typename _Tp, int m, int n> inline
Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const Matx<_Tp,MIN(m,n),1>& d)
{
Matx<_Tp,m,n> M;
for(int i = 0; i < MIN(m,n); i++)
M(i,i) = d[i];
return M;
}
template<typename _Tp, int m, int n> inline
Matx<_Tp, MIN(m,n), 1> Matx<_Tp, m, n>::diag() const
{
diag_type d;
for( int i = 0; i < MIN(m, n); i++ )
d.val[i] = val[i*n + i];
return d;
}
I've looked into this error on the msdn and have looked on the openCV forums, but I couldn't find record of this specific error and I'm not sure how to resolve it.
Is it also problematic that I'm running the 64 bit version of Windows 7? I read that openCV2.2 is compatible however previously while the programs would compile, it kept on saying the .dll files were missing even though the PATH variable and directories were correct.
Thanks,
Jean-Pierre
I had the same issue running Opencv2.2 on 32bit Win7 VS2010 and QT 4.7.2.
I doesn't seem to be an error that affects the actual function of code. When I turned code analysis off as Himanshu jain described above it fixed the problem.
It seems indeed that the option advanced compiler option "/analyze" causes this problem (I'm using OpenCV 2.2 with VS 2008 on Win XP 32bit). I could fix the first error:
In line 365, you got to replace Matx<_Tp,MIN(m,n),1> with diag_type, i.e. this
template<typename _Tp, int m, int n> inline
Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const Matx<_Tp,MIN(m,n),1>& d)
becomes
template<typename _Tp, int m, int n> inline
Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const diag_type& d)
Unfortunately, the 2nd error still occurs -- I found no way to get rid of it but to deactivate \analyze :-(
1>D:\OpenCV2.2\include\opencv2/core/operations.hpp(447) : error C2244: 'cv::Matx<_Tp,,>::diag':
unable to match function definition to an existing declaration
If you find a way to fix this, please let me know -- I think I'll go ahead and post a bug-report-ticket on OpenCV Trac now...