Archived

This topic is now archived and is closed to further replies.

switching compilers

This topic is 5114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lots of compiler errors. I found that Borland was extremely lenient as far as deviating from C standards. It took me a good day or two to completely transfer one of my programs from Borland to Dev-C++. It was only a couple thousand lines long, but the reason it took so long was because I didn''t understand the damn error messages it was spitting at me. One thing to remember, always make sure to write: using namespace std; Borland didn''t care, Dev-C++ does. Good luck.

Share this post


Link to post
Share on other sites
I found my first two problems with switching. The first is the lack of a GUI resource editor. Is there any that Im not seeing? How about something like a add-on for it which has a resource editory?
The other problem is a actural problem. Im getting a parse error at the end of the main source file. I can''t give the code cause Im in school at the moment but what causes this error? It worked fine in Borland.

Also one other thing to stonie, acturally i was getting ALOT more warning in Borland then Im getting in Dev C++. Infact in dev Im not getting any warnings(except the parse error) and in Borland I had over 90(most of which where for the clock code which i never could shrink down).

Share this post


Link to post
Share on other sites
quote:
Original post by StonieJ
One thing to remember, always make sure to write: using namespace std; Borland didn''t care, Dev-C++ does.



Maybe it''s due to difference versions but I''m using the 5.5 free compiler now and I found that if you use iostream.h then you don''t need using namespace std; . On the otherhand, if you include iostream instead then std has to be qualifed or it''ll spit an error out.





--{You fight like a dairy farmer!}

Share this post


Link to post
Share on other sites
quote:
Original post by StonieJ
Lots of compiler errors. I found that Borland was extremely lenient as far as deviating from C standards. It took me a good day or two to completely transfer one of my programs from Borland to Dev-C++. It was only a couple thousand lines long, but the reason it took so long was because I didn''t understand the damn error messages it was spitting at me. One thing to remember, always make sure to write: using namespace std; Borland didn''t care, Dev-C++ does. Good luck.

I only need to use using namespace std; when doing C++ right? I don''t need it in C.
I solved everything else except this parse error. Its really getting to me.

#include "scts.h"

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/* Make the class name into a global variable */
char szAppName[ ] = TEXT("SCTS");

int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int iCmdShow)

{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wndclass; /* Data structure for the windowclass */

/* The Window structure */
wndclass.hInstance = hInstance;
wndclass.lpszClassName = szAppName;
wndclass.lpfnWndProc = WndProc; /* This function is called by windows */
wndclass.style = CS_HREDRAW | CS_VREDRAW; /* Catch double-clicks */
wndclass.cbSize = sizeof (WNDCLASSEX);

/* Use default icon and mouse-pointer */
wndclass.hIcon = LoadIcon (hInstance, TEXT("SCTSico"));
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.lpszMenuName = NULL; /* No menu */
wndclass.cbClsExtra = 0; /* No extra bytes after the window class */
wndclass.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows''s default color as the background of the window */
wndclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);

/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wndclass))
return 0;

/* The class is registered, let''s create the program*/
hwnd = CreateWindow (
szAppName, /* Classname */
TEXT("SCTS"), /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
CW_USEDEFAULT, /* The programs width */
CW_USEDEFAULT, /* and height in pixels */
NULL, /* The window is a child-window to desktop */
NULL, /* No menu */
hInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

/* Make the window visible on the screen */
ShowWindow (hwnd, iCmdShow);

/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}

/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}


/* This function is called by the Windows function DispatchMessage() */

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HBRUSH hBrush; // brush for painting clock
static int cxClient, cyClient; // int of size of window
static HINSTANCE hInstance; // the instance of this program
int DialogCheck; // variable for checking completion of dialog
int PairCheck; // Which pair to check for lighting of Dave3
int cx,cy; // ints for posistion of circles
int mx1,my1; // ints for mouse coordnates on first click
int mx2,my2; // ints for mouse coordnates on second click
int clicknum; // ints for number of clicks
int circnum1,circnum2; // ints for which wire the user is connecting
int i,j; // temp variables for for statement
int resizetest; // temp to test for completion of glc_resize
int bitmaptest; // temp to test for completion of glc_draw_bitmap
int destroytest; // temp to test for completion of glc_destroy
int drawtest; // temp to test for completion of glc_draw_bitmap
HDC hdc; // hdc- main device context
PAINTSTRUCT ps; // the paintstruct to paint the window
glc_context *glC; // Open GL window context
glc_texture *gl_tex; // GL texture for loading bitmaps


switch (message)
{

// window creation call
case WM_CREATE:

if ((hlibrary = LoadLibrary ("glx.dll")) == NULL)
MessageBox (NULL, "Error loading DLL", "Error", MB_OK);
//create brush for clock
hBrush = CreateSolidBrush (RGB (255, 0, 0));
//initilize handle to instace of program
hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
//initilize openGL window
glC=glc_create_context(hwnd);
if(glC!=0){
MessageBox(hwnd,TEXT("failed to create GL context"),TEXT("Error"),MB_OK);
//initilize the timer to 0
time_elapsed=0;
//initilize PairCheck to 1
PairCheck=1;
//initilize clicknum to 1
clicknum=1;

glc_clear_context(glC,255,255,255);
glLoadIdentity();
return 0;

//size message
case WM_SIZE:
//set cxClient to width of window
cxClient = LOWORD (lParam);
//set cyClient to height of window
cyClient = HIWORD (lParam);
//set size of openGL context
resizetest=glc_resize_context(glC,cxClient,cyClient);
if(resizetest!=0)
MessageBox(hwnd, TEXT("Failed to resize GL context"),TEXT("Error"),MB_OK);
return 0;

//Paint message
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);

cx=30;
cy=100;

for(i=0;i<2;i++, cy=cy+100){
for(j=0;j<8;j++, cx=cx+30){
if(cx>=cxClient || cy>=cyClient)
MessageBox(hwnd,TEXT("The circle is outside the window"),ERROR, MB_OK);

glc_draw_circle(glC, 0, 0, 0, cx, cy,20);
}
}

EndPaint (hwnd, &ps);
return 0;

case WM_LBUTTONDOWN:
if(clicknum==1){
cx=30;
cy=100;
mx1 = LOWORD (lParam);
my1 = HIWORD (lParam);
for(i=0;i<2;i++, cy=cy+100){
for(j=0;j<8;j++, cx=cx+30){
if(mx1>cx-10 && mx1cy-10 && my1 clicknum=2;
circnum1=j;
}
}
}
}
else if(clicknum==2){
cx=30;
cy=100;
mx2 = LOWORD (lParam);
my2 = HIWORD (lParam);
for(i=0;i<2;i++, cy=cy+100){
for(j=0;j<8;j++, cx=cx+30){
if(mx2>cx-10 && mx2cy-10 && my2 glc_draw_line(glC,0,0,0,mx1,my1,mx2,my2);
circnum2=j;
swap(circnum1,circnum2,WirePairs);
}
}
}
}
else{
MessageBox(hwnd,"Improper number of Clicks", TEXT("Error"), MB_OK);
}



case WM_TIMER:
switch (wParam)
{
case IDT_TIMER: //timer for clock
time_elapsed++;
//to redraw window with advanced time

return 0;

case IDT_DAVE: //timer for rotation of DAVE3 tester

gl_tex=Dave3Display(hwnd, PairCheck, WirePairs, glC, time_elapsed);
if(gl_tex==0)
MessageBox(hwnd,TEXT("Dave3Display Failed"),TEXT("Error"), MB_OK);
drawtest=glc_draw_bitmap(gl_tex,0,0,134,227,glC,cxClient-150,100,cxClient-16,327);
if(drawtest!=0)
MessageBox(hwnd,TEXT("Failed to draw bitmap"), TEXT("Error"), MB_OK);
++PairCheck;
if(PairCheck>5){
PairCheck=1;
}
return 0;
}

//Menu Operations
case WM_COMMAND:

switch (LOWORD (wParam))
{
case IDM_FILE_NEW:
glc_clear_context(glC,255,255,255);
glLoadIdentity();
InvalidateRect (hwnd, NULL, TRUE);
//reset clock
time_elapsed=0;
//reset WirePairs
WirePairs[0]=1;
WirePairs[1]=2;
WirePairs[2]=3;
WirePairs[3]=4;
WirePairs[4]=5;
WirePairs[5]=6;
WirePairs[6]=7;
WirePairs[7]=8;
//bring up dialog box to get difficulty level
DialogCheck=DialogBox ( hInstance, MAKEINTRESOURCE(IDD_Diff), hwnd, DiffDlgProc);
//make sure the dialog box was created without error
if(DialogCheck==-1)
{
char buf[256];
sprintf(buf, "DialogBox failed with %d", GetLastError());
MessageBoxA(NULL, buf, NULL, 0);
}

//start AI
FaultInducer(WirePairs, hwnd);
//restart dave3 rotation
PairCheck=1;
//start timer for dave3 rotation
SetTimer (hwnd, IDT_DAVE, 250, NULL);
//start timer for clock
SetTimer (hwnd, IDT_TIMER, 1000, NULL);
return 0;

case IDM_FILE_EXIT:
//send message to quit the program
SendMessage (hwnd, WM_CLOSE, 0, 0) ;
return 0;
}
case WM_DESTROY:
glc_clear_context(glC,255,255,255);
glLoadIdentity();
destroytest=glc_destroy_context(glC);
if(destroytest!=0)
MessageBox(hwnd,TEXT("Failed to destroy context"),TEXT("Error"),MB_OK);
if(hlibrary){
FreeLibrary (hlibrary);
}
DeleteDC(hdc);
DeleteObject (hBrush);
PostQuitMessage (0) ;
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}


276 C:\scts\DevC++\scts.c
parse error at end of input

Share this post


Link to post
Share on other sites
Using using namespace std is usually considered sloppy since it floods the global namespace with a lot of stuff that you probably never need.

Parse errors are most often caused by mismatched parenthesis, braces, or brackets; and missing semicolons. There''s a bit too much code for my eyes to see any obvious problems such as those. You might try by commenting out almost everything in the program to see if there are errors, and gradually uncomment blocks until you finally get the parse error.

Share this post


Link to post
Share on other sites