www.digitalmars.com         C & C++   DMDScript  

c++ - How to compile a simple program

reply =?ISO-8859-2?Q?Micha=B3_Kandulski?= <kandul poczta.onet.pl> writes:
Hi,

I'm new to Digital Mars C++ compiler but quite experienced in C++.
Can anyone tell me the command line options to compile this file:

// a.cpp

#include <iostream>
#include <iomanip>
#include <exception>
#include <stdexcept>

int main()
{
	try
	{
		char c;
		std::cin >> c;
		if(c == 'A')
			throw std::runtime_error("'A' pressed!")
	}
	catch(std::exception& e)
	{
		std::cerr << e.what() std::endl;
	}
	return 0;
}

I tried:
dmc -Ic:\dm\stlport\stlport;c:\dm\include -A a.cpp
but the compiler shows a lot of errors.

I also tried with plenty of other combinations, but the results were not 
satisfying (problems with namespace std, whith catch(exception& ) etc.).

Thanks in advance,
Michal
Apr 24 2003
parent "Walter" <walter digitalmars.com> writes:
Try:
    dmc a -I\dm\stlport\stlport -Ae -Ar

"Micha³ Kandulski" <kandul poczta.onet.pl> wrote in message
news:3EA80048.9020706 poczta.onet.pl...
 Hi,

 I'm new to Digital Mars C++ compiler but quite experienced in C++.
 Can anyone tell me the command line options to compile this file:

 // a.cpp

 #include <iostream>
 #include <iomanip>
 #include <exception>
 #include <stdexcept>

 int main()
 {
 try
 {
 char c;
 std::cin >> c;
 if(c == 'A')
 throw std::runtime_error("'A' pressed!")
 }
 catch(std::exception& e)
 {
 std::cerr << e.what() std::endl;
 }
 return 0;
 }

 I tried:
 dmc -Ic:\dm\stlport\stlport;c:\dm\include -A a.cpp
 but the compiler shows a lot of errors.

 I also tried with plenty of other combinations, but the results were not
 satisfying (problems with namespace std, whith catch(exception& ) etc.).

 Thanks in advance,
 Michal

Apr 24 2003