Thread: [Dev-C++] Compiling Separately: Separating Code into Modules ...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: JB M. <jb...@so...> - 2003-06-06 03:08:21
|
Hello,
I am trying to compile a modular program. Is there an order to this =
(i.e. if I'm using Borland C++ Compiler at the DOS command prompt I'd =
have to compile each file separately, but with Dev C++ 4 (an IDE) I'm =
not sure.
When I try to compile the files separately, I get zero errors but =
zero bytes compiled ... what could be wrong?
I anybody can explain the procedure to me, I would appreciate it.
Below is the main() function "Main.cpp" which refers to the header and =
implementation files.
TIA
---
"C makes it easy to shoot yourself in the foot; C++ makes it harder, but =
when you do, it blows away your whole leg."=20
- Bjarne Stroustrup
--
J.B.
-------------------------------------------------------------------------=
--------
#include <iostream>
#include "PromptModule.h"
#include "ErrorHandlingModule.h"
using namespace std;
float GetDividend(void) // Returns dividend, a float
{
float Dividend =3D 0;
cout << "Dividend: ";
cin >> Dividend;
return Dividend; // Returns a copy of Dividend
}
float GetDivisor(void) // Returns the divisor
{
float Divisor =3D 1;
cout << "Divisor: ";
cin >> Divisor;
return Divisor;
}
float Divide
(const float theDividend, const float theDivisor) // Takes =
unmodifiable (const) arguments, returns float
{
return (theDividend/theDivisor); // Returns the result of the =
calculation
}
int main(int argc, char* argv[])
{
SAMSErrorHandling::Initialize();
float ReturnCode =3D 0;
try
{
float Dividend =3D GetDividend();
float Divisor =3D GetDivisor();
cout << Divide(Dividend, Divisor) << endl;
}
catch (...)
{
ReturnCode =3D
SAMSErrorHandling::HandleNotANumberError();
};
SAMSPrompt::PauseForUserAcknowledgement();
return ReturnCode;
}
|
|
From: Luigi S. <gi...@li...> - 2003-06-07 04:24:18
|
On Thu, Jun 05, 2003 at 09:31:41PM -0400, JB Maust wrote: > Hello, > > I am trying to compile a modular program. Is there an order to this (i.e. if I'm using Borland C++ Compiler at the DOS command prompt I'd have to compile each file separately, but with Dev C++ 4 (an IDE) I'm not sure. > > When I try to compile the files separately, I get zero errors but zero bytes compiled ... what could be wrong? > > [...] > > -- > J.B. Hi J.B. With Dev-C++, to produce the binary file of an application whose source code spans more than one file, create a "Project" and add all the source files to it. At that point, you just have to build the project to have the binary produced. -- >> gisan >> |
|
From: JB M. <jb...@so...> - 2003-06-09 18:18:51
|
Mark,
thanks for the tip, but that's not the BIG problem. I am following along
with Jesse Liberty's book SAMS Teach Yourself C++ in 10 Minutes. I
understand the return types, but I was just taking the author's source code
from the web site for the book.
I am more of a Java Programmer currently, but I used to use Borland C++
3.1 back in the late 80's/early 90's.
This is specific to the Dev-C++ IDE (which is why I have written to the
list).
** I get 0 (zero) errors when attempting to compile the project or its
individual files. **
I am trying to compile a few files. I have two implementation files with
associated header files, and the main funtion in a separate file. The book
shows the header files with a .h extension and the implementation files with
a .cpp extension.
My questions are these:
Does the order of files in the project matter?
Does the extension have to be .hpp (or is .h OK) for header
files?
If all of the files are included in the project, shouldn't I just be
able to hit Ctrl-F10 and watch the thing link and compile the files,
and then run?
----- Original Message -----
From: "Mark Livingstone" <mli...@ip...>
To: "JB Maust" <jb...@so...>
Sent: Saturday, June 07, 2003 8:30 AM
Subject: Re: [Dev-C++] Compiling Separately: Separating Code into Modules
...
> On Thu, 5 Jun 2003 21:31:41 -0400, you wrote:
>
> > Hello,
> >
> > I am trying to compile a modular program. Is there an order to this
(i.e. if I'm using Borland C++ Compiler at the DOS command prompt I'd have
to compile each file separately, but with Dev C++ 4 (an IDE) I'm not sure.
> >
> > When I try to compile the files separately, I get zero errors but
zero bytes compiled ... what could be wrong?
> >
> > I anybody can explain the procedure to me, I would appreciate it.
>
> Try returning an int rather than a float ;-)
>
> >
> > Below is the main() function "Main.cpp" which refers to the header and
implementation files.
>
>
> > int main(int argc, char* argv[])
> ^^^^^^^^^^^^
> > {
> > SAMSErrorHandling::Initialize();
> >
> > float ReturnCode = 0;
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> >
> > try
> > {
> > float Dividend = GetDividend();
> > float Divisor = GetDivisor();
> >
> > cout << Divide(Dividend, Divisor) << endl;
> > }
> > catch (...)
> > {
> > ReturnCode =
> > SAMSErrorHandling::HandleNotANumberError();
> > };
> >
> > SAMSPrompt::PauseForUserAcknowledgement();
> > return ReturnCode;
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > }
|
|
From: Luigi S. <gi...@li...> - 2003-06-10 04:57:01
|
On Mon, Jun 09, 2003 at 02:18:16PM -0400, JB Maust wrote: > Mark, > > [...] > > My questions are these: > Does the order of files in the project matter? I have not tested it, but it should not matter > Does the extension have to be .hpp (or is .h OK) for header > files? Both are fine, my personal choice is ".hpp" for C++ and ".h" for C as it helps me tell them apart. > If all of the files are included in the project, shouldn't I just be > able to hit Ctrl-F10 and watch the thing link and compile the files, > and then run? > I do not remember the exact shortcut, but the answer should be yes. Also, header files need not be part of the project as far as compiling is concerned, including them is more a matter of opening those files quickly. -- >> gisan >> |
|
From: Yeoh H. <ye...@ye...> - 2003-06-11 11:07:35
|
----- Original Message ----- From: "JB Maust" <jb...@so...> To: <dev...@li...> Cc: "Mark Livingstone" <mli...@ip...> Sent: Tuesday, June 10, 2003 2:18 AM Subject: Re: [Dev-C++] Compiling Separately: Separating Code into Modules ... > > My questions are these: > If all of the files are included in the project, shouldn't I just be > able to hit Ctrl-F10 and watch the thing link and compile the files, > and then run? > Sometimes it is better to do a Ctrl-F11 Rebuild all. Best Regards, Yeoh -- |
|
From: Mark L. <mli...@ip...> - 2003-06-13 09:06:18
|
On Wed, 11 Jun 2003 23:23:31 -0400 JB Maust <jb...@so...> wrote: > Davis Chapman ... are we talking about Sam's Teach Yourself C++ in 21 > Days, > Fourth Edition ISBN 06732072? > > It looks like Jesse Liberty is creditied for it too. 24 Hours has a > CD-ROM > with Dev-C++, cygwin, and a debugger ... I'm trying to find out which > one it > is ... I remeber from looking in the book store that it is an IDE. This is Sams Teach yourself Visual C++ 6 in 21 days ISBN 0672314037 Comes with MS VC++ 6 Introductory Edition. |