Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
C

CurtD

@CurtD
About
Posts
36
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • New WTF acronyms
    C CurtD

    That is asking far too much of our group.

    The Lounge question

  • New WTF acronyms
    C CurtD

    I have confused several people by using contextual WTF. We use this a lot in our development shop, so I see the need to clarify.

    The Lounge question

  • New WTF acronyms
    C CurtD

    WTF needs to be expanded WoTF = Who TF? WrTF = Where TF? WyTF = Why TF? WnTF = When TF?

    The Lounge question

  • Are you working for free?
    C CurtD

    With the advent of the open source “community”, we have gone from cheap, outsourced development to completely free development. Let’s look at what is happening at google with the Chromium project. http://blog.chromium.org/2009/06/plausible-promise.html[^] Open source projects aren't simply about a runnable binary, they're about the community of users, testers, and developers who devote their time and skills to working on a product they believe in. The last time I looked, google wasn't a charity. How many people donate their time and skills to working for Ford on a car they believe in? From http://www.techcrunch.com/2009/01/18/why-google-employees-quit[^] In one TGIF in Kirkland, an employee informed Eric Schmidt that Microsoft’s benefits package was richer. He announced himself genuinely surprised, which genuinely surprised me. Schmidt, in the presence of witnesses, promised to bring the benefits to a par. He consulted HR, and HR informed him that it’d cost Google 22 million a year to do that. So he abandoned the promise and fell back on his tired, familiar standby (”People don’t work at Google for the money. They work at Google because they want to change the world!”). A statement that always seemed to me a little Louis XIV coming from a billionaire. Mr. Schmidt is truly brilliant – the pied piper of software development. He has made billions, and now has conned the “community” of sandal-clad geeks into working for him for free. Thank God we have people like Mr. Schmidt who will make the personal sacrifice to take on all of those headaches that come with being rich. As George Orwell said, "All animals are equal, but some are more equal than others." Capitalism has been criticized as the little guy making the big guy rich. Well, no one is forcing these people to work for free -- but SHIT.

    The Lounge question html com

  • How to increment a variable [modified]
    C CurtD

    For more fun from the C++ standard: [ Example: i = v[i++]; // the behavior is undefined i = 7, i++, i++; // i becomes 9 i = ++i + 1; // the behavior is undefined i = i + 1; // the value of i is incremented —end example ] I think the best programming practice is to avoid "undefined" behavior.

    modified on Tuesday, March 24, 2009 2:43 PM

    The Weird and The Wonderful tutorial

  • It's the thought that counts
    C CurtD

    Thomas Weller wrote:

    If something like an empty try/catch is discovered in code that I am in charge of (and believe me, I will discover it, thanks to FxCop), I will refuse to accept it for production code. If an error happens and absolutely no action can or should be taken (a very rare case), then at least the exception has to be logged and there has to be a comment in the code that explains why it's OK to just "swallow" the exception in this special case. This is the very least for good code... Regards Thomas

    All I can add is AMEN I will confess that in my code above where I "swallowed" the exception was when a thread was ending and his parent had already disappeared. Which in practice, has never happened. I believe that is the only time I have done this. I sent out an email a few years ago telling people to add exception handling (since I throw exceptions) and their response was to add catch (...) {} all over the place. Fortunatley, I log all exceptions at the source.

    The Weird and The Wonderful

  • How to increment a variable [modified]
    C CurtD

    supercat9 wrote:

    If the variable i is equal to five before the statement, "i = i++;" is executed, would it not be legitimate for the compiler's generated code to read i (five), increment i (yielding and storing six), and then store the read value back to i (setting it back to 5)? If the variable i is not volatile, would not a legitimate optimization thus be to eliminate the statement altogether?

    Well, according to MSDN, the C++ standard does not define the proper behavior when a postfix is applied to a function arg. If anyone knows why they decided to leave it up to the compiler writers instead of deciding on a "standard", I would love to know the reason. The best thing to do is not write code like this. MSDN doesn't say specifically how a postfix is supposed to behave in the example i = i++. But, VS 2005 inc's i before storing it in i -- I assume because of operator precedence.

    supercat9 wrote:

    Out of curiosity, I wonder if there are any compilers which do not always update a variable used with a pre-increment before making use of the pre-incremented value? It's possible to contrive examples where the optimal code would in fact use (var+1) in the expression and then later store the incremented value to the variable, but I doubt compilers would find such optimizations.

    When playing with this example, the optimizer did just that in one case -- it kept (i+1) in a reg, used it a few times, and stored it later. The VS compiler will optimize away code that doesn't do anything.

    void donothing()
    {
    int i = 5;
    i++;
    }

    No code is generated for donothing() and any call to it is ignored.

    The Weird and The Wonderful tutorial

  • How to increment a variable [modified]
    C CurtD

    From MSDN When a postfix operator is applied to a function argument, the value of the argument is not guaranteed to be incremented or decremented before it is passed to the function. See section 1.9.17 in the C++ standard for more information. So, like so much in life, you just roll the dice and take your chances.

    The Weird and The Wonderful tutorial

  • COM and deriveing
    C CurtD

    I think you want to use aggregation. "To expose the interfaces of one COM class as though they were implemented on a second COM class, the second class aggregates the first. "

    COM com help question

  • I just saw this beauty today...
    C CurtD

    That's right out of MFC

    void CHandleMap::DeleteTemp()
    {
    if (this == NULL)
    return;

    The Weird and The Wonderful

  • It's the thought that counts
    C CurtD

    supercat9 wrote:

    Somewhat, but it's easier to limit the effect of catch-and-ignore to a single statement. Realistically, there are quite a few circumstances in which if an error happens very often the developer should be made aware of it, but beyond that there's no particularly useful action the code can take in response to an error.

    In my app, this is the rare case. I think I have one or two and I commented like this catch(Exception e) { // nothing we can do about an error here } Unfortunately, for a lot of people, exception handling consists of catch(...) { } Somewhere they learned this is the proper way to handle exceptions. If it prevents the app from crashing (at this point anyway), that's all you need to do. If you blow up a buffer, hide it and let the next guy deal with it. :mad:

    The Weird and The Wonderful

  • How to increment a variable [modified]
    C CurtD

    supercat9 wrote:

    Wouldn't a more efficient implementation be to simply do nothing, given the lack of a sequence point between the increment and the assignment? Not that I'd generally expect a compiler to find that optimization, but I would have expected code like: mov eax,[_i] ; Fetch value before increment inc dword [_i] ; Do increment mov [_i],eax ; Store fetched valuewhich would, of course, effectively do nothing. BTW, is there any guarantee about the behavior of "do_something(var++)" if do_something references var? What about "i=++i"? Even though it's hard to imagine that "i=++i;" would do anything other than increment "i", I don't think there's any guarantee that it won't?

    This code doesn't "do nothing" i = i++; It still has to inc i and store it in i. It is just a long form of ++i; The VS optimizer usually does a pretty good job. I had to heavily optimize some code a few years ago. I don't remember which VS version I was using, but I was impressed with the code it came up with. In this case it generates mov eax,1 add dword ptr [i],eax This seems a little strange to me. Maybe an "add" is much faster than an "inc". It's been a while since I was optimizing asm code. do_something(var++) is going to push the current var on the stack, call do_something, then inc var. Nothing strange about that.

    The Weird and The Wonderful tutorial

  • How to increment a variable [modified]
    C CurtD

    In c++, VS 2005, the unoptimized code is actually kind of stupid i = i++; mov eax,dword ptr [i (40904Ch)] mov dword ptr [i (40904Ch)],eax mov ecx,dword ptr [i (40904Ch)] add ecx,1 mov dword ptr [i (40904Ch)],ecx It gets i, stores it in i, gets i, increments i, stores it in i. Not sure why it thinks it needs to do the first 2 steps. When I turn on "optimized for speed" (not comfort like me) it generates the exact same (smart) code as ++i;

    The Weird and The Wonderful tutorial

  • It's the thought that counts
    C CurtD

    catching and doing nothing is actually worse. It completely hides the fact that anything went wrong. Which uually means you crash somewhere else later.

    The Weird and The Wonderful

  • It's the thought that counts
    C CurtD

    catch (Exception ex) { //we should probably report errors } :sigh:

    The Weird and The Wonderful

  • Application Dissapearing After Linking With COM
    C CurtD

    What about the debugging tools for Windows (WinDbg, etc.)? These are not as easy to use as VS, but I have been able to find some deep and nasty problems with them. It was a similar situation where I had to debug in release mode with no VS.

    modified on Thursday, March 5, 2009 2:57 PM

    COM csharp c++ question com security

  • Application Dissapearing After Linking With COM
    C CurtD

    Usually an app going *poof* is caused by the instruction ptr sending it off into the Twilight Zone. Most likely your TLB's and DLL's are out of synch. I.e. your application was compiled against a TLB that does not match the DLL.

    COM csharp c++ question com security

  • Why Enrollment in CS/EE Majors decling
    C CurtD

    keencomputer wrote:

    Why CS/EE enrolment are declining in Can/USA. We have heard time geting any decent .net People. Every one wants 60K and can do nothing. Tapas Shome System Software Engineer Keen Computer Solutions 1408 Erin Street Winnipeg, Manitoba Canada R3E 2S8 http://www.keencomputer.com

    We have a similar problem here. Software development managers want $100K, and they don't know anything about software development and they think they can get good developers for the same wage as a union baggage handler. We are now outsourcing all management to children in Bangladesh. They are a hell of a lot cheaper, and since most of them can't speak English, productivity has soared.

    The Lounge csharp com

  • Sql Server would be great if it would install
    C CurtD

    Richard A. Abbott wrote:

    Wrong forum. However, you have learned a valuable lesson. If you ever intend to future uninstall MSSQL Server, then firstly read the manual, or at least the release documentation that came with it. To uninstall requires you do so in a particular manner, not just uninstalling or deleting files etc in a haphazard way. These, for instance, you should read ... How to uninstall an instance of SQL Server 2005 manually[^] How to: Uninstall an Existing Instance of SQL Server 2005 (Setup)[^] and plenty more direct from Microsoft.

    This was more of a rant, since I was reasonably certain I was beyond help (which turned out to be the case). But, I appreciate your response. I did look at the link you provided to the rather lengthy article in MSDN. Alas, after a couple of hours, I got to the "If these steps did not uninstall all the components and all the files that are related to the instance of SQL Server 2005, contact Microsoft Customer Support Services." And I bet they will tell me to reinstall Windows. It must have taken a lot of work to make all of these separate applications so interdependent that they must be uninstalled in a particular order -- and they can't even tell you that during the uninstall. A nice, "We are going to trash your system beyond repair if you do this!" would have been nice. That "encapsulation" thing just never really caught on. And I guess the XCOPY installs that the .NET people have been dreaming about still aren't quite ready. Does anyone think there would be a market for an app that will completely get rid of Sql Server? Always looking for new opportunities. Thanks

    The Back Room database sql-server sysadmin windows-admin json

  • Sql Server would be great if it would install
    C CurtD

    I've been running Sql Server 2005, SP2. I foolishly decided I wanted to look at some of the demo DB stuff that is not part of the normal installation. So, I ran the install again just for the Demo DB stuff. But that wouldn't install because it said I already had a later version of Sql Server -- I assume SP2. So to compound my mistake, I decided to completely uninstall Sql Server and start over and this time install the entire thing. Please don't try this yourselves. First, it wouldn't completely uninstall. Services were left around, files left around, hundreds of registry entries. About all it would do is let me remove it from the installed programs list. Then I tried to reinstall. Well, of course, almost all of that failed because of all the crap still left on my machine. So I deleted all Sql Server app files by hand, rebooted a few times, ran 2 different registry cleaners, went through the registry by hand deleting anything with "sql server" that I could find. Still no luck. After 2 days of this crap, now about 3/4's of Sql Server will install. The rest fails with useless error messages (1603, etc.). So now I guess it is time to wipe my machine and reinstall Windows. Thanks alot MS. The greatest software company in the world -- if I could just get their stuff to install. :mad::mad::mad:

    The Back Room database sql-server sysadmin windows-admin json
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups