Archived

This topic is now archived and is closed to further replies.

STLPort, VC++6.0 and default include path

This topic is 5654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I was trying to reproduce an error and I observed that VC++6.0 does not use the correct include path. I use STLPort, and I have set the include and lib pathes accordingly (first in the priority list). The piece of code is:
  
#include <fstream>

class StreamIn : public std::ifstream {
public:
	void open(const char *s, ios_base::openmode mode = ios_base::in) {
		std::ifstream::open(s, mode);
		};
};
==============================
Compiling...
test.cpp
c:\test\test.cpp(8) : error C2352: ''std::basic_ifstream<char,struct std::char_traits<char> >::open'' : illegal call of non-static member function
        [b]c:\programme\microsoft visual studio\vc98\include\fstream(272) [/b]: see declaration of ''open''
Error executing cl.exe.

test.obj - 1 error(s), 0 warning(s)
  
The error itself is irrelevant here. The question is why does the compiler pick the Dinkumware header? Forever trusting who we are And nothing else matters - Metallica

Share this post


Link to post
Share on other sites
Are you really sure you have the directories correctly set up? A possible problem I can think of is that your include directory points to the root directory of your STLPort installation, and not the "stlport" subdirectory.

Share this post


Link to post
Share on other sites
quote:
Original post by Brother Bob
Are you really sure you have the directories correctly set up? A possible problem I can think of is that your include directory points to the root directory of your STLPort installation, and not the "stlport" subdirectory.


Yes, I am sure.



Forever trusting who we are
And nothing else matters
- Metallica

Share this post


Link to post
Share on other sites
Check the order of the include directories in the options panel of VC++. STLport should be before any standard VC++ dir if you want it to be a priority over MS STL implementation.

I hope that''s the answer you''re looking for.

Share this post


Link to post
Share on other sites
quote:
Original post by MatuX
Check the order of the include directories in the options panel of VC++. STLport should be before any standard VC++ dir if you want it to be a priority over MS STL implementation.

I hope that''s the answer you''re looking for.



Read my original post again: "...I use STLPort, and I have set the include and lib pathes accordingly (first in the priority list)...."

I checked and doublechecked the settings. I remember reading somewhere something about a "built-in" compiler path - something really weird, like a bug or "known issue" in VC++6.0. I cannot find that page any more. I was hoping that someone came across this and could point me to the right direction.


Forever trusting who we are
And nothing else matters
- Metallica

Share this post


Link to post
Share on other sites
quote:
Original post by Mithrandir
You know, I couldn''t figure that out either; VC always seemed to use its own STL stuff no matter what I did.

Only IOStreams, and only because most STL implementations omit IOStreams (some argue that the streams aren''t part of the STL "proper").

Gabriel:
Check if STLPort provides its own IOStreams, and whether it requires recompilation on your native platform. Oh, and the streams classes aren''t designed to be inherited from (they lack virtual destructors, for one thing). It''s better to composite them into your own classes.

Share this post


Link to post
Share on other sites
One possible reason is that you have _STLP_NO_OWN_IOSTREAMS defined (see stl_user_config.h, or elsewhere). When compiling with that define, I get the error in

d:\msdev\vc98\include\fstream(272)

and if I comment that define out I get the error in

d:\msdev\vc98\stlport\stl\_fstream.h(553)

If you are using STLport''s iostreams, you have to build them (see readme file). A downside is that your program is linked to the STLport DLL even if you aren''t using any iostreams (it imports some allocator stuff).

Also, where did you put STLport? I have it under VC98 directory, sa you can see.

Share this post


Link to post
Share on other sites
The IOStreams are readily compiled for VC++, and that path is also set properly.

But the issue is not a linking problem, since we''re talking about the fact that the wrong header file gets included. It''s simple like this: the fstream header file lives both in the STLPort directory and in the M$ include directory. The STLPort dir has a higher priority than the M$ one. Still, the M$ version of fstream gets included. I wouldn''t have noticed it if I hadn''t have a close look to that error message.

Forever trusting who we are
And nothing else matters
- Metallica

Share this post


Link to post
Share on other sites