In file included from isconnected.cpp:1:
C:/Dev-Cpp/include/ras.h:218: error: expected constructor, destructor, or type conversion before '(' token
C:/Dev-Cpp/include/ras.h:218: error: expected ,' or;' before '(' token
C:/Dev-Cpp/include/ras.h:219: error: expected init-declarator before '' token
C:/Dev-Cpp/include/ras.h:219: error: expected ,' or;' before '' token
C:/Dev-Cpp/include/ras.h:222: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:223: error:HRASCONN' does not name a type
C:/Dev-Cpp/include/ras.h:224: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:243: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:244: error: HRASCONN' does not name a type
C:/Dev-Cpp/include/ras.h:245: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:264: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:266: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:267: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:268: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:275: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:277: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:278: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:279: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:286: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:287: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:288: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:289: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:290: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:291: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:292: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:300: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:301: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:302: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:303: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:304: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:305: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:306: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:321: error: `DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:322: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:323: error:HWND' does not name a type
C:/Dev-Cpp/include/ras.h:332: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:333: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:341: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:342: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:350: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:351: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:352: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:353: error:BYTE' does not name a type
C:/Dev-Cpp/include/ras.h:357: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:358: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:359: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:360: error:BYTE' does not name a type
C:/Dev-Cpp/include/ras.h:364: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:365: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:366: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:367: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:368: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:369: error:BYTE' does not name a type
C:/Dev-Cpp/include/ras.h:373: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:374: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:375: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:376: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:377: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:378: error:BYTE' does not name a type
C:/Dev-Cpp/include/ras.h:382: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:383: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:384: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:388: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:389: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:390: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:394: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:395: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:396: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:398: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:407: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:408: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:409: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:411: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:420: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:421: error:BOOL' does not name a type
C:/Dev-Cpp/include/ras.h:440: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:441: error:BOOL' does not name a type
C:/Dev-Cpp/include/ras.h:460: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:461: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:462: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:467: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:468: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:469: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:473: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:474: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:475: error: `WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:479: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:480: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:481: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:485: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:486: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:487: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:488: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:489: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:496: error: BYTE' does not name a type
C:/Dev-Cpp/include/ras.h:497: error:BYTE' does not name a type
C:/Dev-Cpp/include/ras.h:498: error: BYTE' does not name a type
C:/Dev-Cpp/include/ras.h:499: error:BYTE' does not name a type
C:/Dev-Cpp/include/ras.h:503: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:504: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:505: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:506: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:507: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:508: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:509: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:515: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:516: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:517: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:518: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:519: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:520: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:521: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:522: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:523: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:524: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:525: error:WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:526: error: WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:527: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:528: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:529: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:550: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:551: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:552: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:553: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:554: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:555: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:556: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:562: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:563: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:564: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:565: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:566: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:567: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:568: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:569: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:570: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:571: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:572: error:CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:573: error: CHAR' does not name a type
C:/Dev-Cpp/include/ras.h:574: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:575: error: DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:576: error:DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:747: error: typedef BOOL' is initialized (use __typeof__ instead)
C:/Dev-Cpp/include/ras.h:747: error:WINAPI' was not declared in this scope
C:/Dev-Cpp/include/ras.h:747: error: ORASADFUNC' was not declared in this scope
C:/Dev-Cpp/include/ras.h:747: error: expected,' or ;' before '(' token
C:/Dev-Cpp/include/ras.h:748: error: typedefVOID' is initialized (use typeof instead)
C:/Dev-Cpp/include/ras.h:748: error: WINAPI' was not declared in this scope
C:/Dev-Cpp/include/ras.h:748: error:RASDIALFUNC' was not declared in this scope
C:/Dev-Cpp/include/ras.h:748: error: expected ,' or;' before '(' token
C:/Dev-Cpp/include/ras.h:749: error: expected )' before '*' token
C:/Dev-Cpp/include/ras.h:749: error: expected,' or ;' before '*' token
C:/Dev-Cpp/include/ras.h:751: error: typedefDWORD' is initialized (use typeof instead)
C:/Dev-Cpp/include/ras.h:751: error: WINAPI' was not declared in this scope
C:/Dev-Cpp/include/ras.h:751: error:RASDIALFUNC2' was not declared in this scope
C:/Dev-Cpp/include/ras.h:751: error: expected ,' or;' before '(' token
C:/Dev-Cpp/include/ras.h:755: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:757: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:759: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:760: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:761: error: `APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:763: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:765: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:766: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:767: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:768: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:769: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:770: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:771: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:773: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:775: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:776: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:777: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:778: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:779: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:780: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:781: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:782: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:783: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:784: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:785: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:786: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:787: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:789: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:791: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:793: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:795: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:796: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:797: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:798: error: APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:799: error:APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:800: error: `APIENTRY' does not name a type
isconnected.cpp: In function `bool IsConnected()':
isconnected.cpp:14: error: 'struct tagRASCONNA' has no member named 'dwSize'
isconnected.cpp:15: error: 'struct tagRASCONNA' has no member named 'dwSize'
isconnected.cpp:18: error: RasEnumConnectionsA' undeclared (first use this function)
isconnected.cpp:18: error: (Each undeclared identifier is reported only once for each function it appears in.)
isconnected.cpp:20: error: 'struct RASCONNSTATUS' has no member named 'dwSize'
isconnected.cpp:21: error: 'struct tagRASCONNA' has no member named 'hrasconn'
isconnected.cpp:21: error:RasGetConnectStatusA' undeclared (first use this function)
make.exe: *** [isconnected.o] Error 1
Execution terminated
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> How could you tell from the report that it was a linker error?
Context and form.
A compiler message has the form:
<sourcefile>:<line>: [error|warning]: <message>
wheras a linker message has the form:
<objectfile>(address):<sourcefile>:<message>
Also contextually, and "undefined reference" can only be determined by the linker, because its job is to resolve references between object files and libraries.
It is also possible to get pre-processor errors, these have a slightly different form again, try including a non-esistant header file to see an example.
> an access violation (Segmentation Fault) raised in your program.
Now you have a run-time error. Your code is syntactically valid, so compiles, but presumably semantically flawed, so fails in execution. The easiest way to find this kind of error is with a debugger, it will allow you to determine exactly what line in the code causes the access violation (although this may not be the direct cause of the error). Dev-C++'s integrated debugger however has little to recommend it, and I cannot offer advice on its use.
However, in your original code, the code related to RasEnumConnections is entirely incorrect and does not allocate sufficient space. The function provides an array of LPRASCONN, you have allocated a single instance. See teh documentation for how to do this safely.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The way to approach this is to note that the header has no definition of say "DWORD", and than ask yourself, "So which header defined 'DWORD'"?
Another approach is to look up the official documentation of "RasEnumConnections" for example (It is at http://msdn.microsoft.com/en-us/library/aa377284(VS.85).aspx BTW), and note the headers used in the example code there. Admittedly it does not explicitly state that this is necessary, one would have hoped that since it needed it ras.h would have nested windows.h; but it doesn't - at least not in the MinGW Win32 headers.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
isconnected.o(.text+0x42):isconnected.cpp: undefined reference to RasEnumConnectionsA@12'
isconnected.o(.text+0x6b):isconnected.cpp: undefined reference toRasGetConnectStatusA@8'
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What you have now are linker errors. The documentation specifies Rasapi32.lib, but GNU uses a different naming convention (libXXX.a instead of XXX.lib) so you need to link librasapi32.a. This is done by adding -lrasapi32 to the projects linker options.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well the ras.h is in the Dev-Cpp/include file so I guess that's why I assumed that. I gave you the exact code in it's entirety at the bottom. There is nothing else.
I tried all of that before and it does nothing, but thank you for trying to help.
mcomo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Clifford here is the first few lines of the compilers message from above:
C:/Dev-Cpp/include/ras.h:218: error: expected ,' or;' before '(' token
C:/Dev-Cpp/include/ras.h:219: error: expected init-declarator before '' token
C:/Dev-Cpp/include/ras.h:219: error: expected ,' or;' before '' token
C:/Dev-Cpp/include/ras.h:222: error: `DWORD' does not name a type
What made you go to DWORD and not ',' or ';'?
Tks
mcomo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The DWORD message needed no context; to discover why it was complaining about the punctuation I'd have had to taken a look at those specific lines in the header file. Had they been teh only messages, that is what I would have done; but that was not necessary because it was obvious to me that it was a matter of necessary types and macros not being defined (that I guess is where experience comes in).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am having a problem getting a piece of code to compile. I have read the forum and been unable to fix it. I appreciate any help you can give me.
mcomo
Here is the code:
include <ras.h>
include <stdio.h>
bool IsConnected()
{
LPRASCONN TRasCon;
RASCONNSTATUS Tstatus;
DWORD lg;
DWORD lpcon;
bool lReturn;
TRasCon->dwSize = 412;
lg = 256 * TRasCon->dwSize;
lReturn = false;
if( RasEnumConnections(TRasCon, &lg, &lpcon) == 0 )
{
Tstatus.dwSize = 160;
RasGetConnectStatus(TRasCon->hrasconn, &Tstatus);
}
return( lReturn );
}
// Example:
int main( int argc, char *argv[] )
{
if ( IsConnected() )
{
printf( "OK... connected\n" );
}
else
{
printf( "Not connected\n" );
}
return 0;
}
And here is the report:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Project1\Makefile.win"
Executing make clean
rm -f isconnected.o Project1.exe
g++.exe -c isconnected.cpp -o isconnected.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
In file included from isconnected.cpp:1:
C:/Dev-Cpp/include/ras.h:218: error: expected constructor, destructor, or type conversion before '(' token
C:/Dev-Cpp/include/ras.h:218: error: expected
,' or
;' before '(' tokenC:/Dev-Cpp/include/ras.h:219: error: expected init-declarator before '' token
C:/Dev-Cpp/include/ras.h:219: error: expected
,' or
;' before '' tokenC:/Dev-Cpp/include/ras.h:222: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:223: error:
HRASCONN' does not name a typeC:/Dev-Cpp/include/ras.h:224: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:243: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:244: error:
HRASCONN' does not name a type C:/Dev-Cpp/include/ras.h:245: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:264: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:266: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:267: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:268: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:275: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:277: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:278: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:279: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:286: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:287: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:288: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:289: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:290: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:291: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:292: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:300: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:301: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:302: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:303: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:304: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:305: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:306: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:321: error: `DWORD' does not name a type
C:/Dev-Cpp/include/ras.h:322: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:323: error:
HWND' does not name a typeC:/Dev-Cpp/include/ras.h:332: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:333: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:341: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:342: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:350: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:351: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:352: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:353: error:
BYTE' does not name a typeC:/Dev-Cpp/include/ras.h:357: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:358: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:359: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:360: error:
BYTE' does not name a typeC:/Dev-Cpp/include/ras.h:364: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:365: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:366: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:367: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:368: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:369: error:
BYTE' does not name a typeC:/Dev-Cpp/include/ras.h:373: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:374: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:375: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:376: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:377: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:378: error:
BYTE' does not name a typeC:/Dev-Cpp/include/ras.h:382: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:383: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:384: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:388: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:389: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:390: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:394: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:395: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:396: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:398: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:407: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:408: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:409: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:411: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:420: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:421: error:
BOOL' does not name a typeC:/Dev-Cpp/include/ras.h:440: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:441: error:
BOOL' does not name a typeC:/Dev-Cpp/include/ras.h:460: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:461: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:462: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:467: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:468: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:469: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:473: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:474: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:475: error: `WCHAR' does not name a type
C:/Dev-Cpp/include/ras.h:479: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:480: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:481: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:485: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:486: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:487: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:488: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:489: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:496: error:
BYTE' does not name a type C:/Dev-Cpp/include/ras.h:497: error:
BYTE' does not name a typeC:/Dev-Cpp/include/ras.h:498: error:
BYTE' does not name a type C:/Dev-Cpp/include/ras.h:499: error:
BYTE' does not name a typeC:/Dev-Cpp/include/ras.h:503: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:504: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:505: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:506: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:507: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:508: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:509: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:515: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:516: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:517: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:518: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:519: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:520: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:521: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:522: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:523: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:524: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:525: error:
WCHAR' does not name a typeC:/Dev-Cpp/include/ras.h:526: error:
WCHAR' does not name a type C:/Dev-Cpp/include/ras.h:527: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:528: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:529: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:550: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:551: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:552: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:553: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:554: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:555: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:556: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:562: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:563: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:564: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:565: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:566: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:567: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:568: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:569: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:570: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:571: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:572: error:
CHAR' does not name a typeC:/Dev-Cpp/include/ras.h:573: error:
CHAR' does not name a type C:/Dev-Cpp/include/ras.h:574: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:575: error:
DWORD' does not name a type C:/Dev-Cpp/include/ras.h:576: error:
DWORD' does not name a typeC:/Dev-Cpp/include/ras.h:747: error: typedef
BOOL' is initialized (use __typeof__ instead) C:/Dev-Cpp/include/ras.h:747: error:
WINAPI' was not declared in this scopeC:/Dev-Cpp/include/ras.h:747: error:
ORASADFUNC' was not declared in this scope C:/Dev-Cpp/include/ras.h:747: error: expected
,' or;' before '(' token C:/Dev-Cpp/include/ras.h:748: error: typedef
VOID' is initialized (use typeof instead)C:/Dev-Cpp/include/ras.h:748: error:
WINAPI' was not declared in this scope C:/Dev-Cpp/include/ras.h:748: error:
RASDIALFUNC' was not declared in this scopeC:/Dev-Cpp/include/ras.h:748: error: expected
,' or
;' before '(' tokenC:/Dev-Cpp/include/ras.h:749: error: expected
)' before '*' token C:/Dev-Cpp/include/ras.h:749: error: expected
,' or;' before '*' token C:/Dev-Cpp/include/ras.h:751: error: typedef
DWORD' is initialized (use typeof instead)C:/Dev-Cpp/include/ras.h:751: error:
WINAPI' was not declared in this scope C:/Dev-Cpp/include/ras.h:751: error:
RASDIALFUNC2' was not declared in this scopeC:/Dev-Cpp/include/ras.h:751: error: expected
,' or
;' before '(' tokenC:/Dev-Cpp/include/ras.h:755: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:757: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:759: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:760: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:761: error: `APIENTRY' does not name a type
C:/Dev-Cpp/include/ras.h:763: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:765: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:766: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:767: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:768: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:769: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:770: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:771: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:773: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:775: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:776: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:777: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:778: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:779: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:780: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:781: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:782: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:783: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:784: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:785: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:786: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:787: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:789: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:791: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:793: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:795: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:796: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:797: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:798: error:
APIENTRY' does not name a type C:/Dev-Cpp/include/ras.h:799: error:
APIENTRY' does not name a typeC:/Dev-Cpp/include/ras.h:800: error: `APIENTRY' does not name a type
isconnected.cpp: In function `bool IsConnected()':
isconnected.cpp:14: error: 'struct tagRASCONNA' has no member named 'dwSize'
isconnected.cpp:15: error: 'struct tagRASCONNA' has no member named 'dwSize'
isconnected.cpp:18: error:
RasEnumConnectionsA' undeclared (first use this function) isconnected.cpp:18: error: (Each undeclared identifier is reported only once for each function it appears in.) isconnected.cpp:20: error: 'struct RASCONNSTATUS' has no member named 'dwSize' isconnected.cpp:21: error: 'struct tagRASCONNA' has no member named 'hrasconn' isconnected.cpp:21: error:
RasGetConnectStatusA' undeclared (first use this function)make.exe: *** [isconnected.o] Error 1
Execution terminated
> How could you tell from the report that it was a linker error?
Context and form.
A compiler message has the form:
<sourcefile>:<line>: [error|warning]: <message>
wheras a linker message has the form:
<objectfile>(address):<sourcefile>:<message>
Also contextually, and "undefined reference" can only be determined by the linker, because its job is to resolve references between object files and libraries.
It is also possible to get pre-processor errors, these have a slightly different form again, try including a non-esistant header file to see an example.
> an access violation (Segmentation Fault) raised in your program.
Now you have a run-time error. Your code is syntactically valid, so compiles, but presumably semantically flawed, so fails in execution. The easiest way to find this kind of error is with a debugger, it will allow you to determine exactly what line in the code causes the access violation (although this may not be the direct cause of the error). Dev-C++'s integrated debugger however has little to recommend it, and I cannot offer advice on its use.
However, in your original code, the code related to RasEnumConnections is entirely incorrect and does not allocate sufficient space. The function provides an array of LPRASCONN, you have allocated a single instance. See teh documentation for how to do this safely.
Clifford
Hi Everyone:
First, why in the world would you assume that everyone here knows what ras.h is? And that we all are experienced in using it.
In cases like this you should provide us with a link to a site in which we could download ras.h and any documentation that goes with it.
I don't know what ras.h is or how to use it or where to download it, but it only took me about 5 seconds using google to find this:
http://cboard.cprogramming.com/archive/index.php/t-67457.html
I realize that this isn't exactly the same as the errors you gave, it is pretty darn close.
I hope it helps you out.
See Ya
Butch
RAS = Windows Remote Access Services
You need to include <windows.h> ahead of <ras.h>.
The way to approach this is to note that the header has no definition of say "DWORD", and than ask yourself, "So which header defined 'DWORD'"?
Another approach is to look up the official documentation of "RasEnumConnections" for example (It is at http://msdn.microsoft.com/en-us/library/aa377284(VS.85).aspx BTW), and note the headers used in the example code there. Admittedly it does not explicitly state that this is necessary, one would have hoped that since it needed it ras.h would have nested windows.h; but it doesn't - at least not in the MinGW Win32 headers.
Clifford
Clifford,
Thank you for your input. I included <windows.h> and it is narrowed down to three errors now.
I am off to read the article you suggested.
mcomo
Here is the report:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Project1\Makefile.win"
Executing make clean
rm -f isconnected.o Project1.exe
g++.exe -c isconnected.cpp -o isconnected.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
g++.exe isconnected.o -o "Project1.exe" -L"C:/Dev-Cpp/lib"
isconnected.o(.text+0x42):isconnected.cpp: undefined reference to
RasEnumConnectionsA@12' isconnected.o(.text+0x6b):isconnected.cpp: undefined reference to
RasGetConnectStatusA@8'collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
What you have now are linker errors. The documentation specifies Rasapi32.lib, but GNU uses a different naming convention (libXXX.a instead of XXX.lib) so you need to link librasapi32.a. This is done by adding -lrasapi32 to the projects linker options.
Clifford
Sorry... "project's linker options".
Well the ras.h is in the Dev-Cpp/include file so I guess that's why I assumed that. I gave you the exact code in it's entirety at the bottom. There is nothing else.
I tried all of that before and it does nothing, but thank you for trying to help.
mcomo
Clifford here is the first few lines of the compilers message from above:
C:/Dev-Cpp/include/ras.h:218: error: expected
,' or
;' before '(' tokenC:/Dev-Cpp/include/ras.h:219: error: expected init-declarator before '' token
C:/Dev-Cpp/include/ras.h:219: error: expected
,' or
;' before '' tokenC:/Dev-Cpp/include/ras.h:222: error: `DWORD' does not name a type
What made you go to DWORD and not ',' or ';'?
Tks
mcomo
The DWORD message needed no context; to discover why it was complaining about the punctuation I'd have had to taken a look at those specific lines in the header file. Had they been teh only messages, that is what I would have done; but that was not necessary because it was obvious to me that it was a matter of necessary types and macros not being defined (that I guess is where experience comes in).
Clifford
Thank you for your help. I really appreciate you taking your time to help me.
How could you tell from the report that it was a linker error?
I linked as you mentioned and it compiles ok, but I now get this when I run it.
an access violation (Segmentation Fault) raised in your program.
The page pops up first when you run it, but it's a blank black page. then the error pops up.
I have included the compiler report in case it is of some help.
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Project1\Makefile.win"
Executing make clean
rm -f isconnected.o Project1.exe
g++.exe -D__DEBUG__ -c isconnected.cpp -o isconnected.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -g3
g++.exe -D__DEBUG__ isconnected.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" -lrasapi32 -g3
Execution terminated
Compilation successful
Thank You,
mcomo