Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linux gcc 3.2.2 invalid initializer for fpos_t 1

Status
Not open for further replies.

areza123

Programmer
Jul 4, 2002
60
IN
I have a strange problem on my gcc 3.2.2 installed in my SuSE Linux box. It does not compile a simple source file containing fpos_t. Strange. Am I missing some thing? It gives me error invalid initializer fpos_t


 
You initialise an fpos_t by calling fgetpos()

Anything else is a presumption on how the opaque type which is fpos_t is actually implemented.
Code:
fpos_t foo = 0;     // may be ok in some places
fpos_t bar = { 0 }; // may be ok in some other places

--
 
Thanks Salem for the reply. fpos_t is typede'd to long is Sun Solaris but I find that on my Linux it is typedef'd to __c_streampos; On my Sun machine I could use code like

fpos_t obj;
if (!obj) {...}

But this does not seem to be the right approach with __c_streampos? Could you suggest an alternative to the unary exclamation mark please?

 
> if (!obj) {...}
OK, I suppose on your Sun box, it's basically the same as
[tt]if ( obj == 0 )[/tt]
which I suppose could be taken to mean "the beginning of the file".

Perhaps a better way of determining whether you are at the beginning of the file.

This is a bit of a hack, since it's mixing old-style file positioning with new-style file positioning.
Code:
if ( ftell( fp ) == 0 ) /* was if (!obj) */
But then again, there is no fpos_t equivalent of fseek() :(

--
 
hmmm :(, yep I was looking for a better alternative, I guess I'll have to live with this. Thanks for the prompt replies anyways...it always helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top