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

Started by
6 comments, last by silentbaggins 22 years, 2 months ago
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
You have been weighed. You have been measured. You have been found wanting. In what world can you ever beat me?
Advertisement
ok stupid question, of sorts. Foolishly, I forgot about the sprintf and #include <stdio.h> , but can''t there be any other way?
You have been weighed. You have been measured. You have been found wanting. In what world can you ever beat me?
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#ifndef _AFX_NO_AFXCMN_SUPPORT#include <afxcmn.h>			// MFC support for Windows Common Controls#endif // _AFX_NO_AFXCMN_SUPPORT#else#include <windows.h>#endif      


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
ohh yeah, in the project settings, you must set use MFC in a shared DLL...
why don''t you use the STL? std::string
I wouldn''t bring in the pile of code from MFC just for thier crappy string class.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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.
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
You have been weighed. You have been measured. You have been found wanting. In what world can you ever beat me?
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...
www.exportbrands.com/up/riptorn/stuff/string.h

seems ok.

This topic is closed to new replies.

Advertisement