|
Since there is code at the end of the switch statement, my thought was along the lines of "the programmer effed-up". Since that code is called in a base class, adding new CHARTTYPE values will always cause that code to be executed (which draws an unwanted graph component).
IMHO, the code was not originally designed for what it is now being used as. I am just suprised that it is still in the library.
Anyway...
Peace!
-=- James.
|
|
|
|
|
I agree, that's some bad coding.
Here's some questionable coding i found in a widely used TIFF reading library
#define REPEAT8(op) REPEAT4(op); REPEAT4(op)
#define REPEAT4(op) REPEAT2(op); REPEAT2(op)
#define REPEAT2(op) op; op
#define CASE8(x,op) \
switch (x) { \
case 7: op; case 6: op; case 5: op; \
case 4: op; case 3: op; case 2: op; \
case 1: op; \
}
#define UNROLL8(w, op1, op2) { \
uint32 _x; \
for (_x = w; _x >= 8; _x -= 8) { \
op1; \
REPEAT8(op2); \
} \
if (_x > 0) { \
op1; \
CASE8(_x,op2); \
} \
}
while (h-- > 0) {
uint32* bw;
UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++);
cp += toskew;
pp += fromskew;
}
not only is this totally wierd, it is also a complete pain in the ass to debug (cause you can't step into a macro). those UNROLL8 things get expanded into loops of switch statements which are actually unrolled loops themselves, or into repetitions of statements. aahhhHH!!! i had to unroll this code to use it in another app. i almost went crazy.
this really crunches a lot of code into a few terse macros. but holy crap.. it's impossible to understand.
-c
Smaller Animals Software, Inc.
|
|
|
|
|
Though I'm not recommending such exotic layouts, this is an example where having default in the middle of the switch block makes some sense:
switch( dwSomeValue )
{
case SOME_CHARTTYPE1:
case SOME_CHARTTYPE2:
case SOME_CHARTTYPE3:
case SOME_CHARTTYPE4:
case SOME_CHARTTYPE5:
{
break;
}
default:
OutputDebugString("warning: unexpected value; handling as if of the last block\n");
case SOME_CHARTTYPE6:
case SOME_CHARTTYPE7:
case SOME_CHARTTYPE8:
case SOME_CHARTTYPE9:
case SOME_CHARTTYPE10:
{
}
} This construct can help a programmer to detect dangerous default s while still doing something reasonable with them.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How can I change the date of modification or creation of a file in my program
or in windows?
Mazy
|
|
|
|
|
CFile::SetStatus()
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
I am using string in my program.
I have the following lines in my code:(I am showing only relevant lines)
#include<string>
using namespace std;
........
.............
void main()
{
string myname("Stars");
string yourname;
yourname=myname;
cout<<myname;
}
i get="" compilation="" error="" for="" line..yourname="myname" (says="" "=" operator not defined stuff...)
also for line..cout<<myname (says " <<"="" not="" defined...)
how="" can="" i="" achieve="" what="" intend="" doing="" here?also="" how="" use="" cin="">>yourname?
Please help me.
|
|
|
|
|
The only thing your program is missing is an #include <iostream> to use cout . Apart from this, it compiles and works fine.
You may try stripping down your program to a twenty line file (i.e. removing the "irrelevant" lines). My guess is that in the process the bug will dissapear, and possibly this will shed some light.
As for the second question, yes you can use cin>>yuorname , but that only gets till the first whitespace. Use getline(cin,yourname) for retrieving entire lines.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello,
I would like to know if somebody has already implement
set of c++ macros that generate automatically class (constructor and destructor).
I yes can you send me few sample or links?
Thanks for help.
S.
|
|
|
|
|
#define STARTCLASS(classname) \
classname::classname(){} \
classname::~classname(){}
class CMYClass
{
STARTCLASS(CMYClass)
};
Hope this helps,
Bill
|
|
|
|
|
I've got an idea that's been rattling about my nearly vacant cranium for a while now, and I'd like to solicit some ideas here.
I have two locations, 10 km apart, running a text-based retail program using serial ports for communications. The two sites are run on separate serial concentrator chains. For the remote site, the signals leave the server at on a RS422 line at 1.5 Mbps, but are immediately throttled down to 56 kbps as they pass thru a DSU/CSU for transmission over a pair of wires to the remote DSU/CSU and into a concentrator for demultiplexing. The wires between periodically get dug up, which puts a bit of a kink into things at the other end.
Back at the main site, I have a separate WinNT server with a 2 Mbps wireless Internet connection and eight available serial ports. The thought is that I should be able to skip the wire connection completely by reading the serial data stream from the serial server with a port on the NT server, then construct a VPN over the Internet to the remote site, and from there out to the concentrator via a serial port on a machine there. It would immensely increase the speed of the data flow, and eliminate the risk from a drunken contractor on a backhoe. Plus it would save a bundle, since the wire between sites costs me $100/month, and the wireless connection is free (I trade roof space for antennas for service).
I think it would be an interesting project, but I'm curious whether anyone here has tried such a thing, or has any suggestions about how to approach it... One concern of mine is that the hardware approach we're using is, by design, near real-time, while an NT server is far from it. Would the latency be likely to make it fail? Is it a dumb idea from the getgo? Thoughts, anyone?
|
|
|
|
|
consider a for loop like that:
for(i=0;i<=Bound;i++)
In this loop i would like to do an "if" test which if the test succeed i would like to go to the next iteration and if not i do another thing. For example:
if(i>Max||i
|
|
|
|
|
No.
exit() is used to exit the program. break is used to break out of a loop (or case), and continue is used to go to the end of the enclosing loop block. It seems all you need to do is:
for (int i=0; (i <= bound); i++) {
if (!testSucceeds()) {
callAnotherMethod();
}
} /ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
it's exactly i would read so if i do as you like i needn't of a else case!
so i try to do it in my application and test it.
thanks
gerald
|
|
|
|
|
I'm trying to learn the tutorial at this site:
http://www.codeproject.com/bitmap/gditutorial.asp
when I try to build the first tutorial, I get the following error:
--------------------Configuration: Main - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Main.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Main.exe - 2 error(s), 0 warning(s)
what is the problem?
|
|
|
|
|
it seems you have setup a console-app project instead of a win32-app project
Stay heavy ... RockNix///
-------------------------------
Look out for free Win32
Serial Communication Module
for VC++ or Borland C++ Builder
on http://www.klangwerker.de
-------------------------------
|
|
|
|
|
try this:
Project --> Settings --> Link --> Category: Output --> Entry point symbol:
WinMainCRTStartup
|
|
|
|
|
Rajveer wrote:
error LNK2001: unresolved external symbol _main
That's answered in the VC forum FAQ.
--Mike--
"COM didn't solve the old version of DLL hell - it just provided us with a new and improved version of hell."
-- John Simmons, 1/22/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Hi everybody,
I would be glad if someone can tell me wich files are created, installed and/or modified with the installation of Visual C++ 6.
|
|
|
|
|
too many to be listed here!
:wq
|
|
|
|
|
So send me by e-mail.
otavio.romao@inatel.br
|
|
|
|
|
The only possible reason that I can see for you wanting that list is so you can try to rip it off and take a copy of it.
You could just buy it instead.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi, I just want it because one of my application is about to be distributed in many computers and this computers does not have VC++ installed. And the application only works in computers that already had the VC++. So there's why I'm asking the list because from there I could know the files, dll or lib, that I would need.
And here is the problem to you get it: the application is a COM app, an ATL COM AppWizard, which has 6 dll, where 4 is a simple dll and 2 has a dialog derived from CAxDialogImpl. The 4 dll's works perfectly but the others 2, when is about to show the dialog, make the application falls. These dll's are called by a macro from MSWord, the macro calls the 4 dll's perfectly, the problem is just when the macro needs to call the others 2.
One thing that happen is that I developed one app just to test and it had a dialog, a simple dialog, and it works.
Thanks.
Otávio
otavio.romao@inatel.br
|
|
|
|
|
Otávio wrote:
And the application only works in computers that already had the VC++.
Your app should not need VC to run... Are you comiling it in debug mode? If you compile in release mode, it should link to release versions of dll's etc.
You can use dependancy walker to work out exactly which files your app needs, and just distibute them.
Your VC++ license is for one computer... you are not allowed to distibute debug and source componenets of it, or install it on multiple computers.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
hi,
i want to set a style-bit of a dialogresource-editor-created combobox dynamically.
when i do this by ModifyStyle(0,CBS_AUTOHSCROLL); after creation, the combobox ignores the new style.
how can i change that? it seems to need this setting before creation, but where can i set the style before DDX-...() is called (there's no WM_CREATE- message for dialog-editor created controls)?
i have defined a control-variable in the class-wizzard for the combobox, maybe i can set in my views(dialogs) ctor something like m_ctrlCombo.SetStyle(CBS_AUTOHSCROLL);? when i use ModifyStyle() there - i get an ::isWnd()-assertion
does someone know the mysterious function and place?
thx
:wq
|
|
|
|
|
I'm afraid comboboxes do not admit having this style changed after creation. Why it is not an option having the corresponding check box ("Auto HScroll") checked on design time? Other solutions like overriding PreCreateWindow or PreSubclassWindow won't work eithr on your particular scneario.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|