VxWorks Users,
I am starting a new project and I am consisdering whether to use C or
C++. I have installed my MVME2604, downloaded boot code into FLASH, and setup
the VxWorks environment on my Windows NT personal computer. I am trying simple
applications to see how C++ development goes. I have rebuilt VxWorks with
INCLUDE_CPLUS and INCLUDE_CPLUS_IOSTREAMS. I use the default makefile which
does the compile and munching for me. My VxWorks target is set to "automatic"
static constructor instantiation as seen by cplusStratShow(). I can write to
the console with printf(), but not 'cout'. I also lock up the target when I
attempt to load a module with a static class object (ld < run.out). If I make
the object local to a function, it loads and runs fine (except for no 'cout'
output). I have included the sample code below. I know a lot of C++
development under VxWorks is going on, so I must not have things set up
correctly. Can anyone give me some hints on my particular problems, and also
lend advice in general in planning C++ development with VxWorks?
<<test.h>>
#ifndef TEST_H
#define TEST_H
class Tester
{
public:
Tester(void);
~Tester(void);
void Execute(void);
};
#endif
<< test.cpp>>
#include "VxWorks.h"
#include "test.h"
#include "iostream.h"
#include "stdio.h"
Tester::Tester(void) {}
Tester::~Tester(void) {}
void Tester::Execute(void)
{ printf("printf\n"); // This works
cout << "cout\n"; // This does not
}
<<run.cpp>>
#include "VxWorks.h"
#include "test.h"
#include "linklist.h"
#include "stdio.h"
int run(void)
{
Tester testIt;
// When the following line is placed above the function with 'static' to give
it global file scope, it causes
// "ld<run.out" to bomb the target.
LinkList<char *> names;
testIt.Execute(); // Do printf & cout samples
names.Insert("Eric"); // Insert names into the linked list.
names.Insert("Ryan");
names.Insert("Alex");
// Traverse the linked list printing the names (this works).
char **pptr = names.Top();
while (pptr != NULL)
{ printf("%s\n", *pptr);
pptr = ++names;
}
return 0x00fe; // This is the code I get returned to the
shell after "->run ".
}
*----------------------------------------*
| Christopher J. Slominski |
| Computer Sciences Corporation (CSC) |
| 3217 N. Armistead Ave. |
| Hampton, VA 23666 |
| (757) 766-8258 |
| c.j.sl...@larc.nasa.gov |
| NASA Mail Stop 931 |
*----------------------------------------*
--=====================_1980427133==_.ALT
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html><div>VxWorks Users,</div>
<div> I am starting a new project and I am
consisdering whether to use C or C++. I have installed my MVME2604,
downloaded boot code into FLASH, and setup the VxWorks environment on my
Windows NT personal computer. I am trying simple applications to
see how C++ development goes. I have rebuilt VxWorks with
INCLUDE_CPLUS and INCLUDE_CPLUS_IOSTREAMS. I use the default
makefile which does the compile and munching for me. My VxWorks
target is set to "automatic" static constructor instantiation
as seen by cplusStratShow(). I can write to the console with
printf(), but not 'cout'. I also lock up the target when I attempt
to load a module with a static class object (ld < run.out). If I
make the object local to a function, it loads and runs fine (except for
no 'cout' output). I have included the sample code below. I
know a lot of C++ development under VxWorks is going on, so I must not
have things set up correctly. Can anyone give me some hints on my
particular problems, and also lend advice in general in planning C++
development with VxWorks?</div>
<br>
<div><<test.h>></div>
<div>#ifndef TEST_H</div>
<div>#define TEST_H</div>
<br>
<div>class Tester</div>
<div>{</div>
<div> public:</div>
<div> Tester(void);</div>
<div> ~Tester(void);</div>
<div> void Execute(void);</div>
<div>};</div>
<br>
<div>#endif</div>
<br>
<div><< test.cpp>></div>
<div>#include "VxWorks.h"</div>
<div>#include "test.h"</div>
<div>#include "iostream.h"</div>
<div>#include "stdio.h"</div>
<br>
<div>Tester::Tester(void) {}</div>
<br>
<div>Tester::~Tester(void) {}</div>
<br>
<div>void Tester::Execute(void)</div>
<div>{
printf("printf\n");  =
;
// This works</div>
<div> cout <<
"cout\n"; &nb=
sp;
// This does not</div>
<div>}</div>
<br>
<div><<run.cpp>></div>
<div>#include "VxWorks.h"</div>
<div>#include "test.h"</div>
<div>#include "linklist.h"</div>
<div>#include "stdio.h"</div>
<br>
<br>
<div>int run(void)</div>
<div>{</div>
<div> Tester testIt;</div>
<br>
<div> // When the following line is placed above the function with
'static' to give it global file scope, it causes</div>
<div> // "ld<run.out" to bomb the target.</div>
<div> LinkList<char *> names;</div>
<br>
<div>
testIt.Execute();  =
;
// Do printf & cout samples</div>
<br>
<div>
names.Insert("Eric"); &nb=
sp;
// Insert names into the linked list.</div>
<div> names.Insert("Ryan");</div>
<div> names.Insert("Alex");</div>
<br>
<div> // Traverse the linked list printing the names (this
works).</div>
<br>
<div> char **pptr =3D names.Top();</div>
<div> while (pptr !=3D NULL)</div>
<div> { printf("%s\n", *pptr);</div>
<div> pptr =3D ++names;</div>
<div> }</div>
<br>
<div> return
0x00fe; &nb=
sp;
// This is the code I get returned to the shell after "->run
".</div>
<div>}</div>
<br>
<br>
<font face=3D"Lucida Console">
*----------------------------------------*<br>
| Christopher J.
Slominski &=
nbsp;
|<br>
| Computer Sciences Corporation (CSC)
|<br>
| 3217 N. Armistead
Ave. =
|<br>
| Hampton, VA
23666  =
;
|<br>
| (757)
766-8258 &n=
bsp;
|<br>
|
c.j.sl...@larc.nasa.gov &=
nbsp;
|<br>
| NASA Mail Stop
931 &=
nbsp;
|<br>
*----------------------------------------*<br>
</font></html>
--=====================_1980427133==_.ALT--
about 'cout'...
cout << "cout\n";
doesn't necessarely flush the output stream.
Try
cout << "cout" << endl;
or
cout << "cout"; cout.flush();
Best regards.
--
Roberto Nunnari -software engineer-
mailto:roberto...@agie.ch
AGIE - http://www.agie.com
Via dei pioppi 16 tel: +41-91-8069138
6616 Losone """
Switzerland (o o)
=======================oOO==(_)==OOo========================
MY OPNIONS ARE NOT NECESSARELY THOSE OF MY EMPLOYER