Archived

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

c ++ compilers

This topic is 5586 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

i have the visual c ++ introduction version that i bought for 50 bucks a year or so ago.. Im wondering if its a piece of $hit because im having so much trouble with it. Have you guys had any luck with it, or are you running the professional editions? "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein (1879-1955) That is so very true... [edited by - Sabonis on August 26, 2002 2:50:39 PM]

Share this post


Link to post
Share on other sites
If you''re having problems with it, the chances are very very good that they stem from the fact that you''re a beginning programmer, not from limitations of the compiler (which, though not as optimizing as the professional edition, isn''t bad at all.)



Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
What problems are you having?

---
Make it work.
Make it fast.

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites
i never had any trouble with introductory while i had it(it came with a book) I only used it for a month or so before i actually bought standard edition, but i never had any trouble with it (except initialy learning to use it)


-Nicholas Anton
-www.geocities.com/nickanton7/

Share this post


Link to post
Share on other sites
ive been having problems with lockups and freezing with some code i wrote in the past (you can check my threads in the direct x forum). For this particular code, it says that my bDraw is an undeclared identifier, but i got the code straight out of my book. I am really a newb and probably am missing something really obvious, but hey we all gotta start somewhere...


  
#define WIN32_LEAN_AND_MEAN

// The main windows include file

#include <windows.h>
#include <stdlib.h>

int GameInit();
int GameLoop();
int GameShutdown();

HDC g_hDC;
HWND g_hWndMain;


// The window procedure to handle events

long CALLBACK WndProc( HWND hWnd, UINT uMessage,
WPARAM wParam, LPARAM lParam )
{
PAINTSTRUCT PaintStruct; // Structure used during windows painting

HDC hDC;
static HBITMAP hBitmap = 0;// Handle to device context for painting


// Switch the windows message to figure out what it is

switch( uMessage )
{
case WM_CREATE: // The CreateWindow() function was just called

{
// One Time Initialization


return 0;
}

case WM_PAINT: // The window needs to be redrawn

{
// Tell windows we want to start updating the window

hDC = BeginPaint( hWnd, &PaintStruct );


//Tell windows we have finished updating the window

EndPaint( hWnd, &PaintStruct );
return 0;
}

case WM_DESTROY: // The window is about to be closed

{
// Our main window is closing. This means we want our app to exit.

// Tell windows to put a WM_QUIT message in our message queue



PostQuitMessage( 0 );

return 0;
}

case WM_LBUTTONDOWN:
{
bDraw = TRUE;
return 0;
}

case WM_LBUTTONUP:
{
bDraw = FALSE;
return 0;
}

case WM_MOUSEMOVE:
{
HDC hDC = GetDC(g_hWndMain);

static int xPos = LOWORD(lParam);
static int yPos = HIWORD(lParam);


if(bDraw)
{
MoveToEx(hDC,xPos,yPos,NULL);
LineTo(hDC, LOWORD(lParam), HIWORD(lParam));
}

xPos = LOWORD(lParam);
yPos = HIWORD(lParam);
ReleaseDC(g_hWndMain, hDC);
return 0;
}

case WM_CHAR:
{
switch(wParam)
{
case 'x':
{
PostQuitMessage(0);
break;
}
default:
break;
}
return 0;
}

default: // Some other message

{
// Let windows handle this message

return DefWindowProc( hWnd, uMessage, wParam, lParam );
}
}
}

// The windows entry point. The application will start executing here

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR pstrCmdLine, int iCmdShow )
{
HWND hWnd; // The handle to our main window

MSG msg; // The message windows is sending us

WNDCLASSEX wc; // The window class used to create our window


// The name of our class and also the title to our window

static char strAppName[] = "First Windows App, CGM style";

//LOGBRUSH CrossHatchBrush;

//CrossHatchBrush.lbStyle = BS_HATCHED;

//CrossHatchBrush.lbColor = RGB(255,0,255);

//CrossHatchBrush.lbHatch = HS_DIAGCROSS;

//HBRUSH hCrossBrush = CreateBrushIndirect(&CrossHatchBrush);


// Fill in the window class with the attributes for our main window


// The size of this struture in bytes

wc.cbSize = sizeof( WNDCLASSEX );

// The style of the window.

wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
// Useless information. Just set to zero.

wc.cbClsExtra = 0;
// Useless information. Just set to zero.

wc.cbWndExtra = 0;
// The name of our event handler

wc.lpfnWndProc = WndProc;
// A handle to the applications instance

wc.hInstance = hInstance;
// The handle to the brush to use for the window background

wc.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
// A handle to the icon to use for the window

wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
// A handle to a smaller version of the apps icon

wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
// A handle to the cursor to use while the mouse is over our window

wc.hCursor = LoadCursor( NULL, IDC_CROSS );
// A handle to the resource to use as our menu

wc.lpszMenuName = NULL;
// The human readable name for this class

wc.lpszClassName = strAppName;

// Register the class with windows

RegisterClassEx( &wc );

// Create the window based on the previous class

hWnd = CreateWindowEx( NULL, // Advanced style settings

strAppName, // The name of the class

strAppName, // The window caption

WS_OVERLAPPEDWINDOW,// The window style

CW_USEDEFAULT, // The initial x position

CW_USEDEFAULT, // The initial y position

900, 900, // The intiial width / height

NULL, // Handle to parent window

NULL, // Handle to the menu

hInstance, // Handle to the apps instance

NULL ); // Advanced context


g_hWndMain = hWnd;


GameInit();

// Display the window we just created

ShowWindow( hWnd, iCmdShow );
// Draw the window contents for the first time

UpdateWindow( hWnd );


// Start the message loop

while( TRUE )
{
// Check if a message is waiting for processing

if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
// Check if the message is to quit the application

if( msg.message == WM_QUIT )
// Exit the message loop

break;

// Change the format of certain messages

TranslateMessage( &msg );
// Pass the message to WndProc() for processing

DispatchMessage( &msg );
}
else
{
GameLoop();
}

}

GameShutdown();

// Return control to windows with the exit code

return msg.wParam;
}


int GameInit()
{


return 0;



}
int GameLoop()
{


return 0;

}

int GameShutdown()
{

return 0;
}


[Edit: Please always place that much code between source tags. See the FAQ Forum FAQ for details.]

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
That is so very true...

[edited by - Oluseyi on August 26, 2002 4:56:58 PM]

Share this post


Link to post
Share on other sites
yup bDraw is undeclared, ie no where in that code do you tell the compiler what bDraw is, you probably want a line that declares it such as :

BOOL bDraw = true;

which should sort it (possibly), though make sure that line is above the first place that you use bDraw....

[edited by - RobTheBloke on August 26, 2002 4:52:43 PM]

Share this post


Link to post
Share on other sites
Thank you very much, it worked good except that I set it to FALSE so that it wouldnt draw right off the start when the mouse wasnt depressed. How did you know to type that in? It''s a macro isnt it? Then how come you dont have to do that with the RGB macro?

Share this post


Link to post
Share on other sites
What? No. He just declared the bDraw variable. Nothing strange there. No, bDraw isn't a macro, it's a variable you have to declare and just neglected to.

If you're confused by the BOOL thing (it's usually written in lowercase), it's just MSVC's weird way of having another boolean type. AFAIK, the uppercase and lowercase versions are entirely interchangeable.

And the RGB macro is declared. You just can't see it. It's in one of the Windows header files you have included at the beginning of the program (beats me which one).

-Auron

[edited by - Auron on August 26, 2002 5:36:46 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Auron


And the RGB macro is declared. You just can''t see it. It''s in one of the Windows header files you have included at the beginning of the program (beats me which one).



wingdi.h, but include windows.h for it....

Share this post


Link to post
Share on other sites
quote:
Original post by Sabonis
ive been having problems with lockups and freezing with some code i wrote in the past (you can check my threads in the direct x forum).

If the lockups and freezes occur in code you wrote, then obviously your code is causing the lockups and freezes!
Email the book publisher and tell them about the error!!!! I really don''t see how the makers of the book could have let a simple compile error slip through!



Proceeding on a brutal rampage is the obvious choice.

Share this post


Link to post
Share on other sites
You''re right I haven''t read "windef.h" because I can''t personally be bothered to read all the Windows API headers.

Either way, I''m not really that wrong:

quote:

AFAIK, the uppercase and lowercase versions are entirely interchangeable.



In only a select few cases are the two not interchangable, and that''s when Microsoft''s functions return those damned troolean values. But personally, anyone that programs a function of their own that''s designed to return a troolean value should be maimed. It''s the least intuitive thing ever. If a function is meant to return three or more values, it should return an int as is, none of this BOOL crap because it only confuses the code.

Anyway, you can still assign integer values to a standard bool, but if the value is neither 0 nor 1, it''ll be truncated to 1 (that may differ by compiler; I''m not sure).

But now allow me to amend my statement:

In almost all cases, the uppercase and lowercase versions are entirely interchangeable since the integer values 1 and 0 can be assigned successfully to a standard boolean variable. The only exception when using MSVC++ is when a troolean function returns a negative value.

That good enough? Sorry for the "miss information".

-Auron

Share this post


Link to post
Share on other sites
quote:
Original post by RobTheBloke
In my time I've used the introductory/standard/pro & enterprise editions of VC6 and now have VC.net and have never had a problem with any of them.


It crashes a lot for me (especially on XP)

except for .net, 'cause i've never used it

[edited by - mrx02 on August 27, 2002 2:25:31 PM]

Share this post


Link to post
Share on other sites