Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ on VxWorks

96 views
Skip to first unread message

Christopher J. Slominski

unread,
May 28, 1999, 3:00:00 AM5/28/99
to
--=====================_1980427133==_.ALT
Content-Type: text/plain; charset="us-ascii"


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>&nbsp;&nbsp;&nbsp;&nbsp; I am starting a new project and I am
consisdering whether to use C or C++.&nbsp; I have installed my MVME2604,
downloaded boot code into FLASH, and setup the VxWorks environment on my
Windows NT personal computer.&nbsp; I am trying simple applications to
see how C++ development goes.&nbsp; I have rebuilt VxWorks with
INCLUDE_CPLUS and INCLUDE_CPLUS_IOSTREAMS.&nbsp; I use the default
makefile which does the compile and munching for me.&nbsp; My VxWorks
target is set to &quot;automatic&quot; static constructor instantiation
as seen by cplusStratShow().&nbsp; I can write to the console with
printf(), but not 'cout'.&nbsp; I also lock up the target when I attempt
to load a module with a static class object (ld &lt; run.out).&nbsp; If I
make the object local to a function, it loads and runs fine (except for
no 'cout' output).&nbsp; I have included the sample code below.&nbsp; I
know a lot of C++ development under VxWorks is going on, so I must not
have things set up correctly.&nbsp; 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>&lt;&lt;test.h&gt;&gt;</div>
<div>#ifndef TEST_H</div>
<div>#define TEST_H</div>
<br>
<div>class Tester</div>
<div>{</div>
<div>&nbsp; public:</div>
<div>&nbsp;&nbsp;&nbsp; Tester(void);</div>
<div>&nbsp;&nbsp;&nbsp; ~Tester(void);</div>
<div>&nbsp;&nbsp;&nbsp; void Execute(void);</div>
<div>};</div>
<br>
<div>#endif</div>
<br>
<div>&lt;&lt; test.cpp&gt;&gt;</div>
<div>#include &quot;VxWorks.h&quot;</div>
<div>#include &quot;test.h&quot;</div>
<div>#include &quot;iostream.h&quot;</div>
<div>#include &quot;stdio.h&quot;</div>
<br>
<div>Tester::Tester(void) {}</div>
<br>
<div>Tester::~Tester(void) {}</div>
<br>
<div>void Tester::Execute(void)</div>
<div>{
printf(&quot;printf\n&quot;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// This works</div>
<div>&nbsp; cout &lt;&lt;
&quot;cout\n&quot;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// This does not</div>
<div>}</div>
<br>
<div>&lt;&lt;run.cpp&gt;&gt;</div>
<div>#include &quot;VxWorks.h&quot;</div>
<div>#include &quot;test.h&quot;</div>
<div>#include &quot;linklist.h&quot;</div>
<div>#include &quot;stdio.h&quot;</div>
<br>
<br>
<div>int run(void)</div>
<div>{</div>
<div>&nbsp; Tester testIt;</div>
<br>
<div>&nbsp; // When the following line is placed above the function with
'static' to give it global file scope, it causes</div>
<div>&nbsp; // &quot;ld&lt;run.out&quot; to bomb the target.</div>
<div>&nbsp; LinkList&lt;char *&gt; names;</div>
<br>
<div>&nbsp;
testIt.Execute();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Do printf &amp; cout samples</div>
<br>
<div>&nbsp;
names.Insert(&quot;Eric&quot;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;
// Insert names into the linked list.</div>
<div>&nbsp; names.Insert(&quot;Ryan&quot;);</div>
<div>&nbsp; names.Insert(&quot;Alex&quot;);</div>
<br>
<div>&nbsp; // Traverse the linked list printing the names (this
works).</div>
<br>
<div>&nbsp; char **pptr =3D names.Top();</div>
<div>&nbsp; while (pptr !=3D NULL)</div>
<div>&nbsp; { printf(&quot;%s\n&quot;, *pptr);</div>
<div>&nbsp;&nbsp;&nbsp; pptr =3D ++names;</div>
<div>&nbsp; }</div>
<br>
<div>&nbsp; return
0x00fe;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// This is the code I get returned to the shell after &quot;-&gt;run
&quot;.</div>
<div>}</div>
<br>

<br>
<font face=3D"Lucida Console">&nbsp;&nbsp;
*----------------------------------------*<br>
&nbsp;&nbsp; |&nbsp; Christopher J.
Slominski&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;
|<br>
&nbsp;&nbsp; |&nbsp;&nbsp; Computer Sciences Corporation (CSC)&nbsp;
|<br>
&nbsp;&nbsp; |&nbsp;&nbsp; 3217 N. Armistead
Ave.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;
|<br>
&nbsp;&nbsp; |&nbsp;&nbsp; Hampton, VA
23666&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|<br>
&nbsp;&nbsp; |&nbsp;&nbsp; (757)
766-8258&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|<br>
&nbsp;&nbsp; |&nbsp;&nbsp;
c.j.sl...@larc.nasa.gov&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;
|<br>
&nbsp;&nbsp; |&nbsp;&nbsp; NASA Mail Stop
931&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|<br>
&nbsp;&nbsp; *----------------------------------------*<br>
</font></html>

--=====================_1980427133==_.ALT--


Roberto Nunnari

unread,
Jun 7, 1999, 3:00:00 AM6/7/99
to Christopher J. Slominski
Hi Christopher,

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

0 new messages