I am currently trying to program a Rigol DS1054 Oscilloscope to output waveform data. To create this program, I am writing in C++ using Code::Blocks, but I have tried this on four other compilers (Netbeans, Eclipse Mars, Eclipse Juno, Visual Basic 2012) but each one continuously results in an error. Here is what I have done so far:
I have also tried using the 64-bit version as well an I get the same error. This is my current code:
#include <iostream>
#include <visa.h>
using namespace std;
int main () {
ViSession rmSession;
ViOpenDefaultRM(&rmSession);
return 0;
}
The code is very simple, but when run, returns this error:
error: 'ViOpenDefaultRm' was not declared in this scope
This is really weird since it is clearly in the scope. This has been giving me trouble for so many days now - any help would be very appreciated. Thank you!
The function is called viOpenDefaultRM
, not ViOpenDefaultRM
.
For the avoidance of your confusion by such errors in future,
the ViOpenDefaultRM(&rmSession)
in your code is not a declaration of
a function, it is an invocation or call of a function (or would be, if such
a function existed).
In C++, the compiler must see a declaration of a function before it will permit invocations of that function, so that it can tell whether the invocation conforms to the function's signature (or to one of the signatures of an overloaded function), and the declaration must be still in scope at the point of invocation.
The declaration of viOpenDefaultRM
is:
ViStatus _VI_FUNC viOpenDefaultRM (ViPSession vi);
You will find it in visa.h
, and it is in scope at the point where you
have attempted to call ViOpenDefaultRM
because, by including visa.h
before you define main
, it is declared in the scope enclosing main
,
i.e. in global scope.