473,320 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

gcc v2.95.3 --> VS

Hello people,
I have C++ code compiled with GNU compiler gcc version 2.95.3.
which I need to edit and run under windows. (I have access to VS6 and
VS.NET)

What approach is easier?
1) Rewrite it?
2) Add functions so that the original code makes sense?

For example, the following line generates an error:

vector<pair<int, int> > abc;
map<int, vector<int> > xyz;

Thank you

Apr 4 '06 #1
12 1906
pl***@letsdothatagain.com wrote:
Hello people,
I have C++ code compiled with GNU compiler gcc version 2.95.3.
which I need to edit and run under windows. (I have access to VS6 and
VS.NET)

What approach is easier?
1) Rewrite it?
2) Add functions so that the original code makes sense?

For example, the following line generates an error:

vector<pair<int, int> > abc;
map<int, vector<int> > xyz;

Thank you


plize:

What error? What makes you think there is something wrong with this
code? Except perhaps missing header or std namespace.

In general, VS2003.NET (and probably VC6) are better compilers than gcc
2.95, so you should not be having problems if your code is correct C++.
Don't believe the Linux propaganda that VC compilers are bad; every VC
compiler (except perhaps VS2002) has been cutting edge at the time of
release.

David Wilkinson
Apr 4 '06 #2
> Hello people,
I have C++ code compiled with GNU compiler gcc version 2.95.3.
which I need to edit and run under windows. (I have access to VS6 and
VS.NET)

What approach is easier?
1) Rewrite it?
2) Add functions so that the original code makes sense?


To add to David's reply:
Recently I had to port a reasonably complex commandline app from linux to
windows.
on linux they used gcc 2.95, on windows I used VC2003.

since it was a console style app that used 99 % ANSI C++, Porting it was
fairly painless.
there were a few things different, for example building a file path or
things like that.

The only bump in the road was that the original programmer used the readsome
function to read data from an input file stream. it turned out that the
behavior in that specific case was undefined in the standard. gcc did one
thing, vc another.

To port the app and test it against known data cost me just 1 day.
So i think you should definitly try to port it without opting for a rewrite.

there is no clear cut answer to your question.
Basically it all depends on the technology used. if that is portable to
windows then you should be good to go.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Apr 4 '06 #3
Well, I am glad my 'problem' can be solved that easily.
It seams IOSTREAM is the missing link.
I got the following errors when using VS.Net 1.1 (Visual C++) :

#include <iostream.h>
ABC fatal error C1083: Cannot open include file: 'iostream.h': No
such file or directory

int BinarySearch(vector<int> aVector, int n );
ABC error C2062: type 'int' unexpected

Path::Path( istream& is ) {
ABC error C2065: 'is' : undeclared identifier

vector<int> anotherVector;
ABC error C2143: syntax error : missing ';' before '<'
ABC error C2501: 'Prog::vector' : missing storage-class or type
specifiers

Apr 5 '06 #4
> Well, I am glad my 'problem' can be solved that easily.
It seams IOSTREAM is the missing link.
I got the following errors when using VS.Net 1.1 (Visual C++) :

#include <iostream.h>
ABC fatal error C1083: Cannot open include file: 'iostream.h': No
such file or directory

int BinarySearch(vector<int> aVector, int n );
ABC error C2062: type 'int' unexpected

Path::Path( istream& is ) {
ABC error C2065: 'is' : undeclared identifier

vector<int> anotherVector;
ABC error C2143: syntax error : missing ';' before '<'
ABC error C2501: 'Prog::vector' : missing storage-class or type
specifiers


Try
#include <iostream>

instead of
#include <iostream.h>

I.e. remove the .h extension.
this is also true for other C++ standard library headers, like string,
vector, ...

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Apr 5 '06 #5

Bruno van Dooren wrote:
Well, I am glad my 'problem' can be solved that easily.
It seams IOSTREAM is the missing link.
I got the following errors when using VS.Net 1.1 (Visual C++) :

#include <iostream.h>
ABC fatal error C1083: Cannot open include file: 'iostream.h': No
such file or directory

int BinarySearch(vector<int> aVector, int n );
ABC error C2062: type 'int' unexpected

Path::Path( istream& is ) {
ABC error C2065: 'is' : undeclared identifier

vector<int> anotherVector;
ABC error C2143: syntax error : missing ';' before '<'
ABC error C2501: 'Prog::vector' : missing storage-class or type
specifiers


Try
#include <iostream>

instead of
#include <iostream.h>

I.e. remove the .h extension.
this is also true for other C++ standard library headers, like string,
vector, ...

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"


Thank you Bruno,
Thank you all,

Although no error was generated on
#include <vector>

The statement
vector<int> xyz;
does not make sense, as far as Visual C++ 6 is concerned :
error C2143: syntax error : missing ';' before '<'

Apr 5 '06 #6
> Thank you Bruno,
Thank you all,

Although no error was generated on
#include <vector>

The statement
vector<int> xyz;
does not make sense, as far as Visual C++ 6 is concerned :
error C2143: syntax error : missing ';' before '<'


just a guess, but maybe

using namespace std;

is missing from you cpp file? because that is the namespace where vector is
declared.
if it is not used, the compiler will not know that vector is a templace
class.

you have to put it after the include directive, like this:

#include <vector>
using namespace std;
vector<int> anotherVector;

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Apr 5 '06 #7
pl***@letsdothatagain.com wrote:

Although no error was generated on
#include <vector>

The statement
vector<int> xyz;
does not make sense, as far as Visual C++ 6 is concerned :
error C2143: syntax error : missing ';' before '<'


std::vector<int>. All classes from the standard libray are in the "std"
namespace. I'm quite surprised that gcc accepted this code.

Arnaud
MVP - VC

Apr 6 '06 #8
I found it:
int **arrayOfSize = (int **) malloc( size * sizeof(int *));

Apr 6 '06 #9
Thank you all for your help
The number of errors is shrinking...

Now, the following...
int size = 10;
int arrayOfSize[size];

....results in the following errors:
error C2057: expected constant expression
error C2133: 'arrayOfSize' : unknown size
error C2466: cannot allocate an array of constant size 0

Whats the quickest way to fix this?
And how come it was working under GCC?

Apr 6 '06 #10
Thank you all for your help
The number of errors is shrinking...

Now, the following...
int size = 10;
int arrayOfSize[size];

...results in the following errors:
error C2057: expected constant expression
error C2133: 'arrayOfSize' : unknown size
error C2466: cannot allocate an array of constant size 0

Whats the quickest way to fix this?
And how come it was working under GCC?
The fix is simple:
change
int size = 10;
to
const int size = 10;

the reason it works with gcc is that gcc sees that size is a compile time
constant, so it is able to determine the size of the array during
compilation. VC sees that size is a regular variable, so it doesn't compile
the code.
making size a const solves it.

btw you latest postI found it:
int **arrayOfSize = (int **) malloc( size * sizeof(int *));


is not correct. arrayOfSize is an array of pointers to an int, not an array
of ints.
if you just want an array of ints, this would be better:
int *arrayOfSize = (int *) malloc( size * sizeof(int ));

but don't forget to free arrayOfSize when you are done with it, or you will
get a memory leak if you constantly allocate new arrays.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Apr 6 '06 #11
pl***@letsdothatagain.com wrote:
I found it:
int **arrayOfSize = (int **) malloc( size * sizeof(int *));


plize:

As others have pointed out, you are probably missing std:: namespace on
vector:

std::vector<int> xyz;

If gcc 2.95 accepts it without the std::, it is wrong. Don't use malloc;
this is two steps backward.

David Wilkinson
Apr 6 '06 #12
pl***@letsdothatagain.com wrote:
Thank you all for your help
The number of errors is shrinking...

Now, the following...
int size = 10;
int arrayOfSize[size];

...results in the following errors:
error C2057: expected constant expression
error C2133: 'arrayOfSize' : unknown size
error C2466: cannot allocate an array of constant size 0

Whats the quickest way to fix this?
And how come it was working under GCC?


plize:

This is C99, which VC does not support (not even VC8). Again, use
std::vector

std::vector<int> arrayOfSize(10);

David Wilkinson
Apr 6 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
0
by: Arne Schirmacher | last post by:
I want to display a MySQL database field that can contain HTML markup. If I use <esql:get-string> then I get all of the database field, but all tags are escaped which is not what I want. If I use...
34
by: Mark Moore | last post by:
It looks like there's a pretty serious CSS bug in IE6 (v6.0.2800.1106). The HTML below is validated STRICT HTML 4.01 and renders as I would expect in Opera, FrontPage, and Netscape. For some...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
2
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the...
0
by: vdex42 | last post by:
Apologies if this has been asked before, but I haven't been able to find the answer to this yet: My problem is that .NET will not allow me to insert escaped '>' characters (i.e. &gt;) within the...
2
by: santaji | last post by:
I am getting xml string in request attribute in following format &lt;files&gt; &lt;file&gt; &lt;filename&gt;somefile.ext&lt;/filename&gt; &lt;/file&gt; &lt;files&gt; the above string I want to convert to tags. expected...
1
by: VaidehiPawar | last post by:
I am a beginner level in xml..my output page does not convert &gt &lt it shows something like this " &lt;b&gt;Location.&lt;/b&gt;&lt;br /&gt; &lt;UL&gt;&lt;LI&gt;Park Central New York " can anyone help? here is my code ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.