|
Link2006 wrote: I'm wondering if turning on the /GS- switch (that's the Buffer Security Check option, it's used to prevent Buffer Overrun) make the final binary code run slower?
Compile with and without the switch and then investigate...
too much daily WTF for someone... - Anton AfanasyevLast modified: Monday, August 21, 2006 2:50:09 PM -- Did a test program and it made no difference in speed or size.
|
|
|
|
|
PaulC1972 wrote: Compile with and without the switch and then investigate...
I can't tell the difference, maybe that's because both of my machines are rather fast, and my low-end PC is installed with Linux, so I can't test it on that machine.
I'm going to leave that switch on for now.
|
|
|
|
|
Did you notice the modification that I had to my post. I didn't find any difference between the two executables generated with and without the switch. Speed and size were the same. Running a diff between the two executables says they differ
too much daily WTF for someone... - Anton Afanasyev
|
|
|
|
|
PaulC1972 wrote: Did you notice the modification that I had to my post.
Nope, I didn't. The font is too small, I didn't notice it at first until you mentioned it.
|
|
|
|
|
I'm using VC6 SP6 and having nothing but trouble with it these days. I get random break points in my code that I cannot remove, it crashes daily, sometimes it locks during a build cycle. And now, it won't even break at a breakpoint. This is a fresh install too...
Anybody else having similar problems with VC6?
I already have VC7.1 but I'm a little worried it will corrupt my project if I port it over. How does 7 compare to 6?
|
|
|
|
|
Hmmm. When was the last time you did a full rebuild? VS has been known to get confused after a period of usage.
waldermort wrote: How does 7 compare to 6?
It depends. If you are using the stl in V6, then you may have to do some code revision changes. There are also some (minor) compatibility changes wrt message maps etc. So you may not get a smooth 1-1 conversion. However you can it on a copy of your project.
I Dream of Absolute Zero
|
|
|
|
|
6 is supposed to be rock solid compared to 7 and 8, as far as the IDE is concerned! Haven't used VC 6 for 18 months and don't know which SP it was on either.
Kevin
|
|
|
|
|
I use VC6 all day every day on multiple projects and never have any of these problems. Have you tried to a "Clean"?
|
|
|
|
|
VC6 SP6 doing fine over here. Intellisense was always a bit moody (VC++ 7.1 has occasional fits as well when using GDI+ in an MFC project) and ClassView would occasionally quit showing a class after adding a method but nothing that deleting the .ncb or .clw wouldn't fix but I believe those issues were also from before SP6.
waldermort wrote: How does 7 compare to 6?
One of the polls in the last couple of years seemed to indicate that not too many of us use 7. That probably indicates something negative but I've never used it myself to be fair.
|
|
|
|
|
The following errors are returned when I try to use (ios::good == true) as opposed to (ios::good != false)
Code:
void CSentenceAr::readFile(char strFileToRead[MAX_FILENAME_LENGTH])
{
char strLine[MAX_SENTENCE_LENGTH + 1];
fstream fileToRead(strFileToRead,ios::in);
if (ios::good == false) // OR if (ios::good == TRUE)
//which is defined as '1' in afx.h
{while (!fileToRead.eof() && Size < MAX_LINES)
// Read line of text from file and update Sentences.strSentence.
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
strcpy(Sentences.strSentence[Size], strLine);
Size++;
}
}
fileToRead.close();
}
Errors:
SentenceAr.cpp(31): warning C4805: '==' : unsafe mix of type 'bool (__thiscall std::ios_base::* )(void) const' and type 'bool' in operation
SentenceAr.cpp(31): error C2446: '==' : no conversion from 'int' to 'bool (__thiscall std::ios_base::* )(void) const'
SentenceAr.cpp(31): error C2040: '==' : 'bool (__thiscall std::ios_base::* )(void) const' differs in levels of indirection from 'int'
This works though:
{
char strLine[MAX_SENTENCE_LENGTH + 1];
fstream fileToRead(strFileToRead,ios::in);
bool isItGood = ios::good;
if (ios::good != false)
{while (!fileToRead.eof() && Size < MAX_LINES)
// Read line of text from file and update Sentences.strSentence.
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
strcpy(Sentences.strSentence[Size], strLine);
Size++;
}
}
fileToRead.close();
}
The IDE returns isItGood as having a 'true' value.
Jon
|
|
|
|
|
|
Actually the program hangs when I try it that way. Do I have a weird VS2003 version perhaps?
Jon
|
|
|
|
|
I am using VC++ 5.0, MFC, single document. The clipboard icon on my document lights up when there is something in the clipboard. How does it know? Can I get an event message for the clipboard change?
Thanks
|
|
|
|
|
|
|
|
Hello,
I have a dialog-based MFC application, in which there is a RichEdit control, on whichever line the cursor is present inside the RichEdit control, if I press F9 key, that should show one circle with the color that VC++ uses for setting the breakpoint outside the Richedit control but on the dialog box on the same line where the cursor is present. My approach is, that if I have to work out the OnKeyDown message on the RichEdit control as a child of the dialog box, I will have to derive a class from CRichEditCtrl, which I am doing, but still not able to trap the F9 key, so that it will show the circle with that color. Please help.
Software Developer
Sanjay Khapre
|
|
|
|
|
I have been programming for years and have managed to not have to get to involved with implementing my own templates classes, so the following probably has a simple solution.
If I have declared and defined the following template class....
template <typename T> class MyClass{
public:
//.....................public members and functions
protected:
int m_int;
T m_data
};
MyClass<int> my_ints;
MyClass<char> my_chars;
The my_ints instantiation cannot access the my_char.m_int protected member variable even though that member variable is of the same type regardless of the underlying type the template encapsulates.
This should have a simple solution.
Thanks.
JK
|
|
|
|
|
Perhaps it would be clearer if you provided an example of how you are accessing my_char.m_int from my_ints.
|
|
|
|
|
OK Here goes....
Here is a useless example in real life, but this is a simplified example of where I am getting a compiler error.
template <typename T> class MyClass{
public:
//.....................public members and functions
virtual bool copy_whatever_I_can(const MyClass<T>& object);
protected:
int m_int;
T m_data
};
template <typename T> virtual bool MyClass<T>::copy_whatever_I_can(const MyClass<T>& the_char){
m_int = the_char.m_int; //all objects of MyClass have the m_int variable
return true;
}
MyClass<int> my_ints;
MyClass<char> my_chars;
my_ints.copy_whatever_I_can(my_chars); //<----this causes the cannot access protected member error
|
|
|
|
|
MyClass<int> and MyClass<char> are unrelated types. But i'm actually not sure how you can reach that protected error, since by right, the MyClass<int> class only has a function that looks like copy_whatever_I_can(const MyClass<int>& the_char) and this is not a compatible type with MyClass<char>. Is there something I'm missing? (Perhaps you are using a template function instead?)
-- modified at 14:41 Sunday 20th August, 2006
|
|
|
|
|
Actually you are correct. This was a bad example. I am trying to not copy and paste all the code becasue it is complex.
The long and short of it is, forgetting the parameter mistype in the function declaration and defintion, the question is "can templates with different basic underlying types access each others protected members assuming the protected member type is independant of the underlying base type?"
A simple analgoy is a list object.
you have the following protected members;
T* m_data;
int m_length;
All lists have the m_length variable to manage the m_data variable.
I would think there is a way to get an object of type List<int> and List<char> to access each other's m_length variable directly.
I recognize that a public function can return this but lets say for arguments sake I dont want to create the function to return length.
|
|
|
|
|
try this if you are free
template <typename t="">
class ONE
{
public:
template <typename t="">
void CopyThis(ONE<t> &s)
{
_int = s._int;
}
int _int;
T ss;
};
ONE<int> ls;
ONE<char> dir;
dir._int = 100;
ls.CopyThis(dir);
If u can Dream... U can do it
|
|
|
|
|
I think you're misunderstanding templates and member access.
A template is not a class, it's a template. One specialization of MyClass<> doesn't have any special access to the members of a different specialization. Each specialization is a different type, so MyClass<int> can't access protected members of MyClass<char> . The fact that they were both generated from the MyClass template doesn't change things.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
I was getting these errors when trying to use ios::nocreate in order to check whether a file exists prior to opening it:
void CSentenceList::readFile(char strFileToRead[MAX_FILENAME_LENGTH])
{
char strLine[MAX_SENTENCE_LENGTH + 1];
ofstream fileToRead(strFileToRead,ios::nocreate); // ios::nocreate does not seem to exist
while (!fileToRead.eof() && Size < MAX_LINES)
// Read line of text from file and update Sentences.strSentence.
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
Sentences.Insert(strdup(strLine));
Size++;
}
fileToRead.close();
Error
SentenceList.cpp(23): error C2039: 'nocreate' : is not a member of 'std::basic_ios<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
SentenceList.cpp(23): error C2065: 'nocreate' : undeclared identifier
SentenceList.cpp(27): error C2039: 'getline' : is not a member of 'std::basic_ofstream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
I assume that VS2003 has other functions to check whether the file exists, since these are basic C/C+ constructs.
Similarly I never reckoned why I had problems with using protected members of class templates:
SentenceList.h
class CSentenceList : public CGenericList<char*>
…
SentenceList.cpp
CSentenceList::~CSentenceList()
{Sentences.m_pFirst->data = NULL;} // this statement is incorrect but illustrates the point
Error
…SentenceList.cpp(16): error C2248: 'CGenericList<T>::m_pFirst' : cannot access protected member declared in class 'CGenericList<T>'
with
[
T=char *
]
and
[
T=char *
]
…\SentenceClass\SentenceList.cpp(16): error C2248: 'CGenericNode<T>::data' : cannot access protected member declared in class 'CGenericNode<T>'
with
[
T=char *
]
and
[
T=char *
]
GenericList.h
class CGenericList
...
protected:
int m_iCount;
CGenericNode<T> *m_pFirst;
CGenericNode<T> *m_pLast;
...
GenericNode.h
class CGenericNode
...
protected:
T data;
...
Jon
|
|
|
|