Cout not working
by Justin Mosiman · in Torque Game Engine · 06/22/2006 (1:22 pm) · 9 replies
Hello,
cout isn't working for some reason in TGE 1.4. I have the correct header,
But I am getting 24 errors and 3 warnings when I try to compile. It's not liking the iostream part. The first four errors/warnings are:
I've seen some posts that have cout in them, so it must work, but I don't know what I'm doing wrong.
cout isn't working for some reason in TGE 1.4. I have the correct header,
#include <iostream> using namespace std;
But I am getting 24 errors and 3 warnings when I try to compile. It's not liking the iostream part. The first four errors/warnings are:
Quote:
1>c:\Program Files\Microsoft Visual Studio 8\VC\include\crtdbg.h(1088) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\Program Files\Microsoft Visual Studio 8\VC\include\crtdbg.h(1088) : error C2365: 'operator new' : redefinition; previous definition was 'function'
1>c:\Program Files\Microsoft Visual Studio 8\VC\include\crtdbg.h(1088) : error C2078: too many initializers
1>c:\Program Files\Microsoft Visual Studio 8\VC\include\crtdbg.h(1088) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
I've seen some posts that have cout in them, so it must work, but I don't know what I'm doing wrong.
#2
06/22/2006 (1:47 pm)
I was thinking that if you used cout, you could then open the debug and see the output. In Torque, how do you call the debug output?
#3
You use a debugger to debug and if you want a console window you call enableWinConsole(true);
06/22/2006 (1:54 pm)
I suggest you take a look at Con::printf or the regular printf.You use a debugger to debug and if you want a console window you call enableWinConsole(true);
#4
Thanks
06/22/2006 (6:48 pm)
Con::printf worked great for characters, but what if I wanted to output something else, like a variable? I was trying to output a Point3F but got a compile error, and it doesn't look like Torque provides an overloaded function for printf. How do you output a Point3F to the console if you want to see what the value of it is?Thanks
#5
You want to printing them out via printf.
Which fortunately is highly documented in an amazing thing called a 'search engine'.
www.google.com/search?hl=en&q=printf
06/22/2006 (7:15 pm)
Point3f has member fields x, y, and z.You want to printing them out via printf.
Which fortunately is highly documented in an amazing thing called a 'search engine'.
www.google.com/search?hl=en&q=printf
#6
For those who view this thread later, I got it to work by just inserting a string before the variable, such as:
06/22/2006 (8:31 pm)
That's the thing, I get a compile error if I try:Point3F pos = Point3F(0,0,0); Con::printf(pos.x);And the error:
Quote:It wasn't a question of if I know what printf does, it was more of a question of how do you use it to print out variables.
error C2664: 'Con::printf' : cannot convert parameter 1 from 'const F32' to 'const char *'
For those who view this thread later, I got it to work by just inserting a string before the variable, such as:
Point3F pos = Point3F(0,0,0);
Con::printf("output: ",pos.x);This may not be the easiest way to cast pos.x, but it works.
#7
i'm not sure why you didn't check out the google link i posted.
it gives plenty of examples of what you want to do.
i'm surprised your code above works. it's absolutely not the right way to use printf.
the syntax you should be using is: Con::printf("output: %f %f %f", pos.x, pos.y, pos.z);
good luck to you.
06/22/2006 (8:36 pm)
Hi justin.i'm not sure why you didn't check out the google link i posted.
it gives plenty of examples of what you want to do.
i'm surprised your code above works. it's absolutely not the right way to use printf.
the syntax you should be using is: Con::printf("output: %f %f %f", pos.x, pos.y, pos.z);
good luck to you.
#8
The first result from the google link he supplied tells you everything you need to know. Only difference is, is that it's called Con::printf.
Con::printf() = print to console in black
Con::warnf() = print to console in gray
Con::errorf() = print to console in red
...when you view the GUI console accessed from hitting tilde (~); not the DOS-box console.
06/22/2006 (9:03 pm)
Like Orion said, you need a format string and the variables.The first result from the google link he supplied tells you everything you need to know. Only difference is, is that it's called Con::printf.
Con::printf() = print to console in black
Con::warnf() = print to console in gray
Con::errorf() = print to console in red
...when you view the GUI console accessed from hitting tilde (~); not the DOS-box console.
#9
I was originally thinking that printf was different in Torque than it is in the standard library, so that was the basis for my questions.
Thanks again,
Justin
06/22/2006 (9:50 pm)
Thanks Orin and Juan,I was originally thinking that printf was different in Torque than it is in the standard library, so that was the basis for my questions.
Thanks again,
Justin
Torque Owner Stefan Lundmark
You can't use STD functions and whatnot until you remove the Torque operator new define.
There's a good load of info about this on the forums, and a recent thread from today actually discussed this.