Jump to content
  • Advertisement


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


MFC and ANSI C++ string problem with OpenGL and VC++ 6.0

This topic is 6128 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'm attempting to code with Nehe's opengl lesson 2, and trying to write strings and debugging code. Nothing seems to work. Unless I'm wrong, Microsoft's Visual C++ doesn't incorporate ANSI C too well with strings, and I was using #include <string.h> and #include <string>, the compiler err's and now I'm looking to MFC code. I'm wondering if I'm doing the wrong thing by trying to replace windows.h code with the afxwin.h include so I can use MFC's CString. And it's erring out with external err's. So I've found no way to use strings with Microsoft. g++ for linux was much better to play with. How can this be fixed? Edited by - silentbaggins on February 1, 2002 8:34:21 PM

Share this post

Link to post
Share on other sites
there is absolutly nothing wrong with replacing windows.h in my experience.
I use MFC, and the following code replaces windows.h


#ifdef _USE_MFC

//#define VC_EXTRALEAN // Exclude rarely-used stuff
from Windows headers

#include <afxwin.h> // MFC core and standard components

#include <afxext.h> // MFC extensions

#include <afxdtctl.h> // MFC support for Internet
Explorer 4 Common Controls


#include <afxcmn.h> // MFC support for
Windows Common Controls



#include <windows.h>


the only negative of using this, is that it will mean RTTI won't work... which can be annoying.

CString is very stable, but it's user friendly-ness is a bit of a mess...

thus, what I did, was simply made a String class, ala java, which extends from CString, but just replaces things like operators, etc... giving you a user friendly, powerful string class. if you want the code, just ask. (it's just it's long)

this all makes using strings much more like in Java:

cheap example:
String a="a number = " + 3.24f + " where as an int is: " +32 +" ok??";

would work, where as I couldn't get this sort of thing to work with the string container, or CString...

Edited by - RipTorn on February 1, 2002 11:41:58 PM

Share this post

Link to post
Share on other sites
I don''t just use MFC for the string class...

and I''m happy with my current setup, because it works, and works well. And you don''t fix what isn''t broken.

Share this post

Link to post
Share on other sites
Hey that, windows.h replaced worked by the way thank you! I'm sorry for not getting back so soon. Girl problems that night, can't live with'em, can't live with out'em. Agh!

Ok so cool, thanks for the tip on that. STL, ok, cool. Hopefully it'll work like in the linux gcc. Can I keep in touch with you on that? Riptorn, is there a way I can glance over that string code? Gotta apologize for my beginner questions. I plan to return the favor by answering those who ask similiar questions.

Edited by - silentbaggins on February 3, 2002 11:55:21 AM

Share this post

Link to post
Share on other sites
remember it''s MFC... MFC+linux = sleepless nights for eternity.
(ie, it will never work)

now I actually look at this, I realise what a mess it is.. maily because it''s gone through about 8 revisions, 4 where the way the string was handled has changed dramatically...
so, ah, yeah... don''t take too much from it :D

now, see if I can get this right...

seems ok.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!