|
Just for fun (yes I'm sadistic) I set the warning level in VC6 to 4 and I got a butt load of warnings. Most of the warnings are from VC6's header files such as xmemory, xlocale, streambuf, etc.
What's the best way to set a warning level of 4 only on my .cpp/.h files?
Todd Smith
|
|
|
|
|
The STL headers will give tons of warnings at level 4. I think the most-often-seen one is about a debug symbol being longer than 255 characters. Just disable that one and things should go smoother.
--Mike--
Buy me stuff! (Link fixed now)
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Big fan of Alyson Hannigan and Jamie Salé.
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Michael Dunn wrote:
debug symbol being longer than 255 characters.
Ok How do you turn of that particular error?
|
|
|
|
|
Suppose that there are two warnings:
Warning C999901 : Failure destructor generation.
Warning C999902 : Cross reference to destructor.
And you don't want to see them.
You use this to disable the specific 2 warnings:
#pragma warning(disable : 999901 999902)
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
|
When i'm feeling masochistic, i'll wrap just my CPP code with:
#pragma warning(push,4)
and
#pragma warning(pop)
Anything in-between those lines will be compiled with warning level 4, everything else at the default warning level.
--------
Higher education helps your earning capacity. Ask any college professor. --Shog9 --
|
|
|
|
|
Do you need the pop? Will the pragma carry over to the next cpp module?
|
|
|
|
|
Anonymous wrote:
Do you need the pop? Will the pragma carry over to the next cpp module?
No, but if you don't include the whole file, then it's useful; I'll usually not write new code initially at level 4, instead i'll compile w/ level 4 as a final step (along with documentation ).
--------
Higher education helps your earning capacity. Ask any college professor. --Shog9 --
|
|
|
|
|
In order to only have to do it once, do something like this in your StdAfx.h (you are, of course, using PCH correctly...?):
<br />
#pragma warning( push, 1 )<br />
#include <vector><br />
#include <deque><br />
#include <...whatever...><br />
#pragma warning( pop )<br />
That will force the preprocessor & compiler into Warning Level 1 only for the processing of the specified #include s, which should nail most of the warnings.
Peace!
-=- James.
"Fat people are hard to kidnap."
(Try Check Favorites Sometime!)
|
|
|
|
|
I am working with C++ and MSAccess trough ODBC and I have a ligistics nightmare when it comes to releasing new versions of my databases. Right now, If I make a change to my database structure I have to write a little patch program that will add, remove, or edit columns or tables in the database and these things are hardcoded and can only work for specific versions.
I was wondering if anyone knows of any utility programs that will let me make the changes over multiple versions. Basically, if the user has version 1.0 and wants to upgrade to 3.0 the utility will then change the existing database appropriatly. Or a user wants to go from 2.0 to 3.0 and so forth.
So a utility that will let me store what needs to changed in the database from version to version, and make these changes on upgrade. That way, the users don't lose any data and the program won't crash from trying to access a column that was not in the older versions.
Thanks in advance,
I also posted this on the Database board, but this moves faster, sorry if it is in the wrong spot
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
|
I tried to install the Soap Toolkit 2.0, but it fails to register SOAPISAP.dll on install. No sample runs cause it can't create the COM objects it needs. I can't register any of the DLLs manually. I run WinXP and VS .NET.
Any ideas ?
Thanks
|
|
|
|
|
I just loaded Visual C++.net along with the existing Visual C++ 6.0. Has anyone got these two together on one machine. I seem to be having strange results on programs that worked fine before on C++ 6.0. I am running XP and after loading Visual C++.net a week ago I had to redo my whole machine as everything became unstable.
Also what's with the 1 hour loading time and 2gbyte size for the new compiler. So far it's feeling like a big step backwards.
|
|
|
|
|
|
Make sure your system INCLUDE, LIB and PATH environment variables don't mess up.
|
|
|
|
|
Hey,
I'm not sure if this is actually a CString problem or not. I'm working on a program that reads a log file, converts it to an HTML table, then saves it as a user defined HTML file. When I first started I hardcoded it to save as output.html. Then I added a little edit control that lets you define the file. This is the code I use for it:
void CMFC2Dlg::OnSave()
{
CStdioFile File;
CString FileName;
GetDlgItemText(IDC_OUTNAME, FileName);
if(File.Open(FileName, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite | CFile::typeText))
File.WriteString(LogConvert);
else
MessageBox("Could not write file", FileName, MB_OK);
}
I thought it might have got stuck in my ram somewhere, but I restarted my computer and it still doesn't work... I'm clueless.
Any help is very much appreciated, thanks in advance!
|
|
|
|
|
Have you tried stepping through the code to see where it fails ? I won't bother nagging you about how you should use proper C++ streams
Christian
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Yea, I tried stepping through it... It stepped through the code fine.
I deleted the entire thing, then restored files one by one from the recycling bin until it compiled, and that gave me some errors in the code, so I fixed those and now it works... wierd. :p
I wouldn't bother being nagged about proper c++ strings. This is my very first Visual C++ program, so I'm just doing whatever works till I find out better :P
|
|
|
|
|
Emearg wrote:
I wouldn't bother being nagged about proper c++ strings. This is my very first Visual C++ program, so I'm just doing whatever works till I find out better
Then this is the perfect time for you to learn to do things properly instead of MFC *crap*.
If you #include fstream, you can create a file like this:
using std::ofstream.
ofstream f("c:\file.txt");
f << Mystring << MyInt << MyCustomTypeThatIWroteAStreamHandlerForAfterReadingChristiansArticleOnCP;
f.close();
It's neater, it works just as well, and it's portable ( you can use it where you aren't using MFC, you can use it on any C++ platform in fact ).
I would suggest you look at the stl instead of the awful MFC containers, iostreams instead of MFC file handling, and be aware of std string, although CString is often a better choice.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Emearg wrote:
File.WriteString(LogConvert);
I have had a lot of trouble when I used a CString with WriteString. Use a char array.
char str[1024];
strcpy(str,LogConvert);
File.WriteString(str);
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Nish, Nish, why on earth would you do it this way ?
File.WriteString (LogConvert.GetBuffer(LogConvert.GetLength());
LogConvert.ReleaseBuffer;
This is precisely the sort of ad hoc 'create something big enough to always work' stuff that C++ does away with needing. strcpy is a C function.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
I guess I still have my bad habits from C left inside me
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Christian Graus wrote:
File.WriteString (LogConvert.GetBuffer(LogConvert.GetLength());
LogConvert.ReleaseBuffer;
Using GetBuffer( ) has to call ReleaseBuffer( ). If I code this way:
File.WriteString(LogConvert.operator LPCTSTR());
Is there any difference between GetBuffer() and operator LPCTSTR() ?
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
operator LPCTSTR() is the same as casting to LPCTSTR, which is less ugly IMO
(LPCTSTR) LogConvert
The fact that they provide the operator leaves me confused as the why they have GetBuffer as well. I'll have to check.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
The reason that they have the operator LPCTSTR() and GetBuffer() is that the first converts a CString to an LPCTSTR, while the second returns a pointer to the buffer of the CString as an LPTSTR. The LPCTSTR is a const TCHAR*, which doesn't allow the buffer to be modified, while the LPTSTR allows the contents of the buffer to be modified.
The operator LPCTSTR() from CString allows a CString to be used anywhere that you need an LPCTSTR. This means that you can simply write:
CStdioFile File; // assume that this file is already open for write...
CString LogConvert; // assume that this string is filled in...
File.WriteString( LogConvert ); // since WriteString takes an LPCTSTR, this is all that is needed.
This is one of the things about CString that I prefer over std::string. For std::string, you would need to explicitly convert the string:
std::string LogConvert;
File.WriteString( LogConvert.c_str() );
Some people prefer the method used by std::string, as you are in control of when the conversion is made, but I prefer the simplicity of just passing the string. This is particularly useful when interfacing with legacy code. For new code, I probably would just pass the string object.
Best regards,
John
|
|
|
|
|
Howdy all,
Does anyone have any suggestions for an API function similar to DrawDibDraw(), which can handle a negative height bitmap, aka an inverted bitmap?
MSDN explicitly states that DrawDibDraw can't handle a negative height parameter, but I can't find a useful alternative.
Please don't tell me I have to flip the bitmap by hand
TIA,
Pete
|
|
|
|