compiling a program to run in DOS mode
- by dygi
I write a simple program, to run in DOS mode. Everything works under emulated console in Win XP / Vista / Seven, but not in DOS. The error says: this program caonnot be run in DOS mode. I wonder is that a problem with compiler flags or something bigger.
For programming i use Code::Blocks v 8.02 with such settings for compilation:
-Wall -W -pedantic -pedantic-errors
in Project \ Build options \ Compiler settings
I've tried a clean DOS mode, booting from cd, and also setting up DOS in Virtual Machine. The same error appears.
Should i turn on some more compiler flags ? Some specific 386 / 486 optimizations ?
UPDATE
Ok, i've downloaded, installed and configured DJGPP. Even resolved some problems with libs and includes. Still have two questions.
1) i can't compile a code, which calls _strdate and _strtime, i've double checked the includes, as MSDN says it needs time.h, but still error says: _strdate was not declared in this scope, i even tried to add std::_strdate, but then i have 4, not 2 errors sazing the same
2) the 2nd code is about gotoxy, it looks like that:
#include <windows.h>
void gotoxy(int x, int y)
{
COORD position;
position.X = x; position.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position);
}
error says there is no windows.h, so i've put it in place, but then there are many more errors saying some is missing from windows.h, I SUPPOSE it won't work because this functions is strictly for windows right ? is there any way to write similar gotoxy for DOS ?
UPDATE2
1) solved using time(); instead of _strdate(); and _strtime(); here's the code
time_t rawtime;
struct tm * timeinfo;
char buffer [20];
time ( &rawtime );
timeinfo = localtime ( &rawtime );
strftime (buffer,80,"%Y.%m.%d %H:%M:%S\0",timeinfo);
string myTime(buffer);
It now compiles under DJGPP.
UPDATE3
Still need to solve a code using gotoxy - replaced it with some other code that compiles (under DJGPP).
Thank You all for help. Just learnt some new things about compiling (flags, old IDE's like DJGPP, OpenWatcom) and refreshed memories setting DOS to work :--)