Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbPrint() newbie question

Author
Message
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 13th Jan 2008 22:02
Why doesn't this work?



Error:
John Goewert
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Cornfield, MO
Posted: 13th Jan 2008 22:05
Because you are trying to send a "string" where it is expecting a char* or an LPSTR. While they are similar, they are not equal.

http://www.thescripts.com/forum/thread137848.html

Blah - http://www.john.goewert.org
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 13th Jan 2008 22:07
You can't do this:



Instead you must do it like this:



I believe the String class you're using has the function c_str(), if not substitute it for the equivalent function that will convert it to a c-style string.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 14th Jan 2008 05:16
Mike - You should learn the "main stream" way - but I whipped up my own string lib - and its works great. Small, concise, and easy to use.

THE HEADER








The Main Code



Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 14th Jan 2008 09:22 Edited at: 14th Jan 2008 09:23
This is what I've tried:



However, this still doesn't work.

As I understand the code above: the sprintf command:
-Combines "Hello here is my string:" and Smessage ().
-Converts the combination into a char array (czTemp).
-The identifier %s tells it to convert to a string.

The C_str command:
-Returns S message as a C string instead of a standard string.

So, there are more than one definitions of a 'string' in C++? Please correct me if any of that is wrong.

Error:
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 14th Jan 2008 09:44
Michael, you understand it correctly. And, yes - in some way - there are various strings in C++. The most often used string type is an array of char's (as derived from original C language), but it's very unpleasant to work with those strings so there are several different kinds of string classes which makes it easier (like "string" class in your example).

Now, your code is ok, but you need to fix your project settings to be able to link it properly. See my post on this thread:

http://forum.thegamecreators.com/?m=forum_view&t=121186&b=22
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 14th Jan 2008 10:41
Right, I've read everything you wrote in that thread and what I understand is:

-In my project, there are some libraries that conflict with each other and so I need to exclude some.
-I should change the 'use of mfc' setting to 'Use MFC in a Static Library'.
-To exclude a library I goto 'Proj.sets. | Linker | Input | Ignore Specific Library' and add in libraries that I want to exclude.

Let me know if what I say above is wrong. So, now I need to work out what libraries to exclude.. how do I do that?
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 14th Jan 2008 10:52
Quote: "-In my project, there are some libraries that conflict with each other and so I need to exclude some."


Right.

Quote: "-I should change the 'use of mfc' setting to 'Use MFC in a Static Library'."


Not right. MFC is another topic, which we won't discuss here because those linker error you got are from C runtime. That you will set in Proj.sets | C/C++ | Code Generation | Runtime Library.

Quote: "-To exclude a library I goto 'Proj.sets. | Linker | Input | Ignore Specific Library' and add in libraries that I want to exclude."


Right. And in the mentioned thread I even discussed how to choose which libraries to exclude (I placed there some useful link to MSDN where there are examples of what libraries you need).
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 14th Jan 2008 10:53
(This is one of the reasons I used my own string lib)

I didn't have issues using the STRING lib, so I just wrapped some basic stuff in that does the job.

What you say is Correct (though I'm not sure about the Static MFC link thing but that sounds like it should work with the DarkGDK as we don't have a debug lib to link with and I think static makes it so its treated like a "external Dll") I could be wrong here... TempIceP?

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 14th Jan 2008 11:35 Edited at: 14th Jan 2008 11:36
Yay I have got it to work. For reference:
-Changed 'Project settings | C/C++ | Code Generation | Runtime Library' to 'Multi-threaded (/MT)'
-Changed 'Project settings | Linker | Input | Ignore Specific Library' to 'libc.lib;msvcrt.lib;libcd.lib;libcmtd.lib;msvcrtd.lib' (see link 1)
-Changed 'Project settings | Linker | System | Sub System' to 'Windows (/SUBSYSTEM:WINDOWS)'. (see link 2)


Link 1:
http://msdn2.microsoft.com/en-us/library/aa267384(VS.60).aspx

Link 2:
http://msdn2.microsoft.com/en-us/library/aa267384(VS.60).aspx

Login to post a reply

Server time is: 2024-05-03 22:25:39
Your offset time is: 2024-05-03 22:25:39