So what do your files look like now, and what errors are you getting?
So what do your files look like now, and what errors are you getting?
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
no errors, it compiles and runs, but it doesnt show the colors, it seems like it thinks the functions are void when they shouldnt be.
main.cpp:
color.hno includes)Code:#include "global.h" #include "color.h"
colorIt.cpp:Code:// INTERFACE FUNCTIONS: // font colors>> void tred(); void tgreen(); void tblue(); void tmagenta(); void tteal(); void ttan(); void tdefault(); void tred_i(); void tgreen_i(); void tblue_i(); void tmagenta_i(); void tteal_i(); void ttan_i(); void tdefault_i(); // background colors: void bred(); void bgreen(); void bblue(); void bmagenta(); void bteal(); void btan(); void bdefault(); void bred_i(); void bgreen_i(); void bblue_i(); void bmagenta_i(); void bteal_i(); void btan_i(); void bdefault_i(); void face_intro(); void face_darktech(); void face_menu_titlebar(); void cosmos_logo(); void dark_logo(); void light_side(); void red_i(); void green_i(); void blue_white(); void teal_white(); void blue_grey();
Code:#include "color.h" #define _WIN32_WINNT WINVER #ifdef WIN32 #endif // INTERFACE FUNCTIONS: // font colors>> void tred() { #ifdef WIN32 HANDLE hstdo; hstdo = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hstdo, FOREGROUND_RED); #endif } // ect.. other color functions like tred()
Did you add WIN32 to your preprocessor definitions? From your previous post, it sounds like WIN32 is not defined.
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
Maybe you ought to change the order of #includes to match how it was previously, if that has changed. Like maybe "color.h" needs to see _WIN32_WINNT.
What the little #else #error test showed you is that you are compiling nothing right now. Before may have been great, but you may have inadvertently changed the magic order.Code:#include "color.h" #define _WIN32_WINNT WINVER
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
well i defined something in colorIt.cpp, that is about WIN32. Its actually also defined in main.cpp also. But what do you mean by defining it as a predepressor? It has worked before, but only when it was in the main.cpp file.
I just tryed putting color.h below and it still does not show color. Oh im really sorry for all hte trouble im causing.
>>well i defined something in colorIt.cpp, that is about WIN32.
"something" isn't good enough. You need to define WIN32 if you want that code between #ifdef WIN32 and #endif to run. Ideally, you should use a preprocessor option passed to the compiler, but if you just put #define WIN32 at the top of your files (or in files included) it should work.
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
But if I put #define WIN32 in the C/C++ compiler properties under predpresser, it will give me infinite errors, like it doesnt know any of my variables when I do that.
I even tryed it the other way, but putting
#define WIN32 at the VERY top of every file, and same result
Investigate how you are supposed to use a #define for the IDE?Originally Posted by DarkMortar
What variables? You haven't show us any yet.We can't read your computer screen, perhaps you could share the mystery with us... or wait until our crystal balls get back from cleaing.Originally Posted by DarkMortar
Do you still get the #error statement even with this attempt?
Last edited by Dave_Sinkula; 05-25-2006 at 10:25 PM.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Ok this time, I properly defined WIN32 in the predepresser and it compiles and runs now. Nothing else was changed. BUT it STILL doesnt show the colors like it should.
BUT: the #error in blue_grey() function generates an error in the compile when I add this:
ERROR:Code:#else #error !WIN32
1>.\colorIt.cpp(366) : fatal error C1189: #error : !WIN32
So now you know that information, now what?
As you can see, for the functions you want to show color, you are in fact compiling no code to change the color. So how could it run with the latest changes?Originally Posted by DarkMortar
[edit]'predepresser' - funny.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
but dood, when I even left out the #error statements in the color functions, it compiled but didnt show the color! hmm?
Don't take it out. That's what tells you when you are doing it right or not.Originally Posted by DarkMortarWhen you are doing it right, the message will go away.Code:#include <stdio.h> int main(void) { #define MACRO #ifdef MACRO puts("MACRO is defined"); #else puts("MACRO is NOT defined"); #endif #undef MACRO #ifdef MACRO puts("MACRO is defined"); #else puts("MACRO is NOT defined"); #endif return 0; } /* my output MACRO is defined MACRO is NOT defined */
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Example!
Code:#include <iostream> #define X1 #ifdef X1 void x1() { std::cout<<"HI!!!!!"; } #endif #ifdef X2 //This functon does not get called! void x1() { std::cout<<"Hello!!!!!!!"; } #endif int main() { x1(); std::cin.get(); }Code:#include <iostream> #define X2 #ifdef X1 //This functon does not get called! void x1() { std::cout<<"HI!!!!!"; } #endif #ifdef X2 void x1() { std::cout<<"Hello!!!!!!!"; } #endif int main() { x1(); std::cin.get(); }
Woop?
Ok that does make sense to me now, but I put #define WIN32 at the top and it gives me errors in the functions like this:
Code:1>.\colorIt.cpp(235) : error C3861: 'SetConsoleTextAttribute': identifier not found 1>.\colorIt.cpp(242) : error C2146: syntax error : missing ';' before identifier 'hstdo' 1>.\colorIt.cpp(243) : error C3861: 'GetStdHandle': identifier not found 1>.\colorIt.cpp(244) : error C3861: 'SetConsoleTextAttribute': identifier not found 1>.\colorIt.cpp(251) : error C2146: syntax error : missing ';' before identifier 'hstdo' 1>.\colorIt.cpp(252) : error C3861: 'GetStdHandle': identifier not found 1>.\colorIt.cpp(253) : error C3861: 'SetConsoleTextAttribute': identifier not found 1>.\colorIt.cpp(260) : error C2146: syntax error : missing ';' before identifier 'hstdo' 1>.\colorIt.cpp(261) : error C3861: 'GetStdHandle': identifier not found 1>.\colorIt.cpp(262) : error C3861: 'SetConsoleTextAttribute': identifier not found 1>.\colorIt.cpp(271) : error C2146: syntax error : missing ';' before identifier 'hstdo' 1>.\colorIt.cpp(272) : error C3861: 'GetStdHandle': identifier not found 1>.\colorIt.cpp(273) : error C3861: 'SetConsoleTextAttribute': identifier not found 1>.\colorIt.cpp(280) : error C2146: syntax error : missing ';' before identifier 'hstdo' 1>.\colorIt.cpp(281) : error C3861: 'GetStdHandle': identifier not found 1>.\colorIt.cpp(282) : error C3861: 'SetConsoleTextAttribute': identifier not found 1>.\colorIt.cpp(282) : fatal error C1003: error count exceeds 100; stopping compilation
ect...
What the file looks like:
Code:#define WIN32 #define _WIN32_WINNT WINVER #include "color.h" #ifdef WIN32 #endif // INTERFACE FUNCTIONS: // font colors>> void tred() { #ifdef WIN32 HANDLE hstdo; hstdo = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hstdo, FOREGROUND_RED); #endif }