By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,505 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,505 IT Pros & Developers. It's quick & easy.

Converting Visual Studio C++ to G++

P: n/a

I am currently attempting to convert Visual Studio C++ code to run on a
Sun Solaris machine using a G++ compiler. Most of the code compiles
fine however, certain operations do not compile correctly. In visual
studio C++

fpos_t foo

foo = 0;
foo = 1 + foo;
foo = 3;
will compile correctly because the + operation is overloaded for fpos_t
in Visual Studio C++. I am unsure how to overload the operator on the
Solaris Machine. Since fpos is part of <stdio> library I do not want
to alter the standard library, is there a way for me to create a free
function within the file/files I am using fpos_t and overload the +
operation for fpos_t objects? Is there an alternate quick fix I am not
thinking of? Perhaps a dummy class of some sort?
Thank you for any help you can give me
Jack Tzeng

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
jack1728 wrote:
I am currently attempting to convert Visual Studio C++ code to run on a
Sun Solaris machine using a G++ compiler. Most of the code compiles
fine however, certain operations do not compile correctly. In visual
studio C++

fpos_t foo

foo = 0;
foo = 1 + foo;
foo = 3;
will compile correctly because the + operation is overloaded for fpos_t
in Visual Studio C++. I am unsure how to overload the operator on the
Solaris Machine. Since fpos is part of <stdio> library I do not want
to alter the standard library, is there a way for me to create a free
function within the file/files I am using fpos_t and overload the +
operation for fpos_t objects? Is there an alternate quick fix I am not
thinking of? Perhaps a dummy class of some sort?
Thank you for any help you can give me
Jack Tzeng


I don't understand the question...

I don't have a Solaris machine handy, but in Windows
(MS VC 6.0) and Linux (g++) 'fpos_t' is usually a 'C' typedef
in <stdio.h> for some integral type (32 or 64 bit int, long, etc).

What does an 'overload' operator or a 'class' have to do
with it?

Regards,
Larry
Jul 23 '05 #2

P: n/a
Larry I Smith wrote:

I don't have a Solaris machine handy, but in Windows
(MS VC 6.0) and Linux (g++) 'fpos_t' is usually a 'C' typedef
in <stdio.h> for some integral type (32 or 64 bit int, long, etc).

What does an 'overload' operator or a 'class' have to do
with it?


The standard says that fpos_t is an object type (but not an array)
capable of representing every position in a file. There's no
requirement for it to be an integral type

In Borland C++, std::fstream::pos_type is a class that wraps a long,
and has an error status value. I presume it is to provide nicer
behaviour if you try and go past the end of the file.

I suppose the OP's compiler does something similar with fpos_t.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.