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
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Thats why i hate c++

Thats why i hate c++

Scheduled Pinned Locked Moved The Weird and The Wonderful
c++helplearning
77 Posts 32 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Stephen Dycus

    Do you only develop for yourself? Saying that performance is fine on YOUR computer doesn't mean it's good for your users. Also, no I've never been stuck for weeks on a problem with C++ code... I've been stuck getting libraries to work (opengl, sfml, etc) but I know how to properly debug... In fact if you are hiding behind C# instead of learning to debug with unmanged languages, you are hurting yourself in the long run... Those skills are relevent in all languages and will help you the next time C# throws you a fancy error message that you can't make heads or tales of.

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #54

    Stephen Dycus wrote:

    Those skills are relevent in all languages and will help you the next time C# throws you a fancy error message that you can't make heads or tales of.

    You are so right, but he is not interested in hearing that. When that day comes, he will treat us to yet another rant with the title 'That's why i hate c#'.

    At least artificial intelligence already is superior to natural stupidity

    1 Reply Last reply
    0
    • V Vasily Tserekh

      When i was beggining to make some programs i had to make a small ellectronic book in c++. It started ok, i managed to make a reader and an editor and then came the worst error a programmer can have. When I compiled the program it went smoothly but when i openned it from windows it showed and internal error message whit no message. I suspected it was an I/O error because when i copied the program to c: or d: didnt showed the error but when i placed in other folder that wasnt the root it showed the error message

      F Offline
      F Offline
      Florin Jurcovici 0
      wrote on last edited by
      #55

      That's nothing. It happened to me twice, in different environments (one using MSVC and one using gcc): the binary runs flawlessly when compiled in debug mode, and fails highly reproductibly when compiled in optimized mode. Both times the culprit was some smartass programmer who controlled what code gets compiled depending on build type in some libraries.

      1 Reply Last reply
      0
      • A Alan Balkany

        Yes, the .NET framework DOES sometimes malfunction and do strange things. But I have to agree with VT that it's much more common in C++.

        "Microsoft -- Adding unnecessary complexity to your work since 1987!"

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #56

        How do you arrive at that conclusion? You do realize that comparing a framework with a programming language is quite illogical. Perhaps you think that the code generated by a C++ compiler is less stable than that generated by a C# compiler? In what way? And why does that problem affect compilers across different releases and manufacturers? Or you think that the libraries for C++ compilers are less stable than the .Net framework. Maybe, but how does that make C++ inferior? Let's just design a brand new framework for C++ and everything is well.

        At least artificial intelligence already is superior to natural stupidity

        A 1 Reply Last reply
        0
        • L Lost User

          How do you arrive at that conclusion? You do realize that comparing a framework with a programming language is quite illogical. Perhaps you think that the code generated by a C++ compiler is less stable than that generated by a C# compiler? In what way? And why does that problem affect compilers across different releases and manufacturers? Or you think that the libraries for C++ compilers are less stable than the .Net framework. Maybe, but how does that make C++ inferior? Let's just design a brand new framework for C++ and everything is well.

          At least artificial intelligence already is superior to natural stupidity

          A Offline
          A Offline
          Alan Balkany
          wrote on last edited by
          #57

          1. C# gives better error messages. C++'s error messages are more often cryptic. 2. C# catches more errors at compile time than C++. At this point the error is clearer. 3. C#'s managed code has more context information (which may account for the better error messages.) 4. C#'s run-time checks give you an explicit error, as opposed to C++ where the reported error location (if a location is even given) is far from where the error occurred. 5. C#s code is more stable for reason 4; a C++ error (e.g. exceeding array bounds) may exist for years before it produces a crash or wrong results. A better framework COULD be designed for C++; my comments were on the existing implementations.

          "Microsoft -- Adding unnecessary complexity to your work since 1987!"

          L S 2 Replies Last reply
          0
          • V Vasily Tserekh

            It is alwayas good a people that have a lot more knowledge and experience than you to shut your mouth. I was not insulting you i just can see how superior is c++ because you can make device drivers on it in that case, i can argue than asm code is superior to c++ because you can make device drivers and its more flexible. and you will tell me that you are not productive with asm, the same thing i tell you with c++ and C# c++ is to computer programming like php for web programming, they are OLD, misconceived, with a lot of patches, modified on the run, the syntax is awfull and yet eveyone says is wonderfull because everything is built on that. That is not an argument at least for me You tell me that c++ code is a lot faster, and I recommend you to read some articles because in a lot of use cases c# is faster. and BTW Inline assembly was a technique that enabled C++ programmers to put I386 assembly language directives into the C++ code. It was a horrible hack that made all kinds of assumptions about the processor (in a portable language?) and was used quite often when something fast and low-level was needed.

            K Offline
            K Offline
            krsmichael
            wrote on last edited by
            #58

            Inline asm allows a developer to access hardware that the c/c++ could not access. An example of this is the CPUID machine instructions. Before C#, if you wanted information about your hardware, you would write something like this.

            unsigned long value;
            \_highestFunction = 0;
            
            union VendorUnion
            {
            	unsigned long vendorLong;
            	unsigned char vendorArray\[4\];
            } vendorTail;
            
            unsigned char temp;
            
            \_\_asm
            {
            	mov eax, 0x00
            	cpuid
            
            	mov value, eax
            	mov vendorTail.vendorLong, ecx
            }
            
            \_highestFunction = value;
            
            // swap some values so that the switch statement will be more readable...
            temp = vendorTail.vendorArray\[0\];
            vendorTail.vendorArray\[0\] = vendorTail.vendorArray\[3\];
            vendorTail.vendorArray\[3\] = temp;
            
            temp = vendorTail.vendorArray\[2\];
            vendorTail.vendorArray\[2\] = vendorTail.vendorArray\[1\];
            vendorTail.vendorArray\[1\] = temp;
            
            switch (vendorTail.vendorLong)
            {
            	case 'ter!': \_vendorID = eAMDK5; break;
            	case 'cAMD': \_vendorID = dAMD; break;
            	case 'auls': \_vendorID = eCentaur; break;
            	case 'tead': \_vendorID = eCyrix; break;
            	case 'ntel': \_vendorID = eIntel; break;
            	case 'Mx86': \_vendorID = eTransmeta; break;
            	case 'aCPU': \_vendorID = eTransmeta; break;
            	case ' NSC': \_vendorID = eNationalSemiconductor;	break;
            	case 'iven': \_vendorID = eNexGen; break;
            	case 'Rise': \_vendorID = eRise; break;
            	case ' SIS': \_vendorID = eSiS; break;
            	case ' UMC': \_vendorID = eUMC; break;
            	case ' VIA': \_vendorID = eVIA; break;
            }
            
            unsigned long \_eax, \_ebx, \_ecx, \_edx;
            
            \_\_asm
            {
            	mov eax, 0x01
            	cpuid
            
            	mov \_eax, eax;
            	mov \_ebx, ebx
            	mov \_ecx, ecx
            	mov \_edx, edx
            }
            
            
            // setting eax to 3 will get the cpu id
            if (\_highestFunction >= 3)
            {
            	\_\_asm
            	{
            		mov eax, 0x03
            		cpuid
            
            	}
            }
            

            Writing that same code in pure ASM would be a pain but in this case, you can use the higher level language when appropriate but use the assembly to access the hardware. The ASM being platform dependent is irrelevant at this point because that is the point. The only time that C# or Java can outperform C++ is when a loop is being performed and the VM can rearrange the byte codes to predict execution. C++ is statically built so the speed is constant. Other than that, I am aware of no instances of C# or Java being faster than well written C++.

            1 Reply Last reply
            0
            • A Alan Balkany

              1. C# gives better error messages. C++'s error messages are more often cryptic. 2. C# catches more errors at compile time than C++. At this point the error is clearer. 3. C#'s managed code has more context information (which may account for the better error messages.) 4. C#'s run-time checks give you an explicit error, as opposed to C++ where the reported error location (if a location is even given) is far from where the error occurred. 5. C#s code is more stable for reason 4; a C++ error (e.g. exceeding array bounds) may exist for years before it produces a crash or wrong results. A better framework COULD be designed for C++; my comments were on the existing implementations.

              "Microsoft -- Adding unnecessary complexity to your work since 1987!"

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #59

              1. C++ really does not have a monopoly on stupid error messages. No matter where they turn up, I look them up in MSDN only twice: For the first and the last time. After that I know what they are about. 2. Really? What kind of errors are these? I can think of many cases where the compiler cannot distinguish between an error and intention and must assume that you know what you are doing. By design that's more the case for C++. You can't have both freedom and safeguards against unintentional mistakes at once, but that's a matter of preferences and not really a flaw. 3. I used to be quite capable to supply those myself quite easily with my own exception classes and error logging. It was not really hard to write an exception class, stuff it into a library and consequently use it. 4. Never had any problems with that. I came from assembly programming and was used to having no automatic checks at runtime. Instead of testing array bounds I usually preferred to ensure that the code to calculate the pointers to the item could not violate the bounds. Often by simple means like an assembly macro. Or by design, like using a byte as index for arrays with 256 items. Simple, safe, costs nothing :) Another way would be to code in a way that must lead to an exception unless everything is correct. 90% of all errors are avoidable, like forgetting to check for null pointers at the proper locations. If it is ensured that an exception will be raised, then those locations should be found during testing and then eliminated forever. This works very well for me. I have one recent web application that now has been running for 18 months without a single failed job. 5. By my experience thats true for every language and library, it's just the scenarios in which those errors occur that change. My best defense against that (also in managed languages) is to keep the code as simple and straightforward as possible. No design for design's sake. No heaping one framework upon another. And, of course, a layer where no error gets past without being recorded, preferranly with as much information as possible. In a way I have turned every operation of the application into a unit test. A transparent design, a few practices and monitoring your application is all that is needed.

              At least artificial intelligence already is superior to natural stupidity

              1 Reply Last reply
              0
              • A Alan Balkany

                1. C# gives better error messages. C++'s error messages are more often cryptic. 2. C# catches more errors at compile time than C++. At this point the error is clearer. 3. C#'s managed code has more context information (which may account for the better error messages.) 4. C#'s run-time checks give you an explicit error, as opposed to C++ where the reported error location (if a location is even given) is far from where the error occurred. 5. C#s code is more stable for reason 4; a C++ error (e.g. exceeding array bounds) may exist for years before it produces a crash or wrong results. A better framework COULD be designed for C++; my comments were on the existing implementations.

                "Microsoft -- Adding unnecessary complexity to your work since 1987!"

                S Offline
                S Offline
                Stephen Dycus
                wrote on last edited by
                #60

                If you're not putting debug prints into your crashing code, you're not doing it right. XD I think this is the OP's main problem. He's expecting his compiled exe to tell him what's wrong instead of figuring it out himself. It's really not that hard to log some basic info to a text file... or even to the console. You'll know exactly where the crash happens because debug statement X was never printed. *shrug* Just seems like bad programming IMO. I love C# personally, it's quick and easy for simple tools but it's by no means a replacement for C++.

                1 Reply Last reply
                0
                • V Vasily Tserekh

                  When i was beggining to make some programs i had to make a small ellectronic book in c++. It started ok, i managed to make a reader and an editor and then came the worst error a programmer can have. When I compiled the program it went smoothly but when i openned it from windows it showed and internal error message whit no message. I suspected it was an I/O error because when i copied the program to c: or d: didnt showed the error but when i placed in other folder that wasnt the root it showed the error message

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #61

                  I can sympathize (in terms of trying to find some elusive “error”). The other day, I could not compile a new C# COM server I was building … kept getting errors like: “expecting this …” or “expecting that …”. I counted brackets; braces; everything lined up, but it still wouldn’t compile. (I should mention that some of the code was copied from MSDN). So, I started refactoring. If I typed it out, it would compile; if I copied and pasted snippets, the compile would fail. In the end, it turned out to be a “subtract” (i.e. “ - “) in a math statement. The code I had copied contained an “unprintable” character after the “-“ (which happened to be at the end of a line due to a copied MSDN statement that spanned multiple lines) … retyping the “-“ made the problem go away. You could only “see” the problem if you hit “End” on that particular line because the cursor would land over one extra position.

                  1 Reply Last reply
                  0
                  • K krsmichael

                    Vasily, by definition, C# is a sandbox. That is what managed code means. You run in a sandbox and don't have access to the process space. Sandbox. Got it? So, you want one thing? Write me a device driver in C#. Another? Write me an HTTP server that can handle 100,000+ simultaneous connections. I can do that in C++ using overlapped IO and completion ports. I hear the same arguments from the Java guys. My Grails on Groovy on Java framework can handle 200 simultaneous connections and it doesn't matter because I can throw more hardware at it. Do you have any idea how many machines you will need to replace the 1 C++ machine? You talk about making system DLL calls. What do you think those DLLs are written in? And, BTW, if you don't have the C/C++ run-times installed, those DLLs will not load either. I gave you the solution to your problem. I use QT. QT's streams are a wonder as well. And you know what, they are a lot faster too. QT and C# with WPF gives you declarative programming. Guess what, C++ and QT are much faster again. Both are equivalently trivial. You allude to an idea that I don't have a clue. Go back and read what I wrote about insulting people when you make a bold statement and then try to argue the point. My guess is you are about 15 years old. You are learning to program and you still have holes in your knowledge. Me, I'm 50 years old. I've been doing this since the Apple II days. I've done mainframe. I can do assembly, PASCAL, PL1, C, C++, C#, Perl, Python, JavaScript, Java, HTML, device drivers, DLLs, servers, clients, OpenSSL, mobile devices, and much more. I can do all this stuff on Windows, Windows CE, MacOSx and Linux. Oh, and BTW, you can't do inline ASM. M

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #62

                    So, you're saying you can still "do" PL1? (Actually, it was PL/I; which I "did"). What you "did" and what you can "do" (expertly) today are two different things. While I may have been an "expert" 1401/7010 Autocoder at one time, mentioning it today is meaningless.

                    K 1 Reply Last reply
                    0
                    • V Vasily Tserekh

                      I surely know what i am talking about, HOW TO CLEAN A CODE THAT YOU CANT DEBUG. and surely you have ever worked with c++ builder 6, c++ builder doesnt have a debug and release version it only has a single output, instead of giving new ideas you talk about how good you are and how ignorant i am. I will make it simple so your mind can understand!!! step one -you write code step two -you compile that code step tree your ide launches the .exe and you try it step four you test your program and i does just fine step five you go to the application folder and make double click on the executable step six the application show and erro message with no error at all now you get it, how CAN YOU ISOLATE THE PROBLEM and when you isolate it what will you do if you can trace what is wrong

                      P Offline
                      P Offline
                      patbob
                      wrote on last edited by
                      #63

                      Situations like those are when I usually pull down the OS symbols and install them. Break the app in the debugger while the errant error dialog is being displayed and look at the stack trace. One can't necessarily debug the OS code with the symbols, but they allow an accurate stack trace report to be generated by the debugger. NT's function names are remarkably informative. Between the function names and google, and I can often get a pretty good clue about what the OS is trying to do on my behalf. Occasionally, when I'm really lucky, I can even look at the parameter values being passed (when the deubgger deigns to report them) and start to figure out what's wrong. Then, there's always printf's. Or the GUI equivalant, MessageBox() calls. Make them unique and try to bracket the line of your code that's causing the error. And the best part, no debugger is required -- you can even debug fully optimized production code if you have to (how else does one find an optimizer bug?). Or you can do as suggested, comment out blocks of code in a sort of binary search for the troublesome line... although I find that a lot harder to do in practice than the above techniques.

                      We can program with only 1's, but if all you've got are zeros, you've got nothing.

                      1 Reply Last reply
                      0
                      • V Vasily Tserekh

                        I surely know what i am talking about, HOW TO CLEAN A CODE THAT YOU CANT DEBUG. and surely you have ever worked with c++ builder 6, c++ builder doesnt have a debug and release version it only has a single output, instead of giving new ideas you talk about how good you are and how ignorant i am. I will make it simple so your mind can understand!!! step one -you write code step two -you compile that code step tree your ide launches the .exe and you try it step four you test your program and i does just fine step five you go to the application folder and make double click on the executable step six the application show and erro message with no error at all now you get it, how CAN YOU ISOLATE THE PROBLEM and when you isolate it what will you do if you can trace what is wrong

                        K Offline
                        K Offline
                        KP Lee
                        wrote on last edited by
                        #64

                        The point the other two posters were making is that there are two exe files created. One in the debug folder and one in the release folder. Both are application folders. The one in the debug folder should work just like the IDE launch.(I'm not sure breakpoints are reccognized outside the IDE. I seem to remember not without linking to the mapping file. Don't remember the file type, but if you map to it and blow up, the IDE is brought up for you and your local environment at the time of blowing up is available for viewing. I read how to do this in 2005, very useful at the time, got away from programming for a while so don't remember how that is done) So, you KNOW you are double-clicking the DEBUG folder's version of the code and it doesn't work? Do you know how to bring up the IDE from a double-click? Earlier, you said the drive letter you started from is causing the problem. From that, I assumed you started the app from a cmd file. Since you are double-clicking, are you navigating to the drive causing the problem in the app? If not, how do you know it is a drive permission problem?

                        1 Reply Last reply
                        0
                        • C Charles Oppermann

                          Vasily Tserekh wrote:

                          yes I know but at least in managed languages you get a nice error message not a blank error messsage, thats why I hate c++

                          You "hate" C++ because you don't understand it. To be clear, in .NET languages like C# and VB.NET (and similarly in Java), when there is a unhandled fault, the end user is presented with a exception that includes a stack trace. Generally you would never want a end-user to see a stack-trace. You can get exactly the same thing in C++ if you choose to, but it requires additional work that is done for you in a managed environment. Generally stack traces are available in a debugger.

                          /* Charles Oppermann */ http://weblogs.asp.net/chuckop

                          K Offline
                          K Offline
                          KP Lee
                          wrote on last edited by
                          #65

                          I don't like C++ either, but it's because I rarely use it and I like the pampering you get with managed code. I do like the IDE and I definitely don't completely understand it. I have to agree with you, that I don't like it when something goes wrong and I don't understand what is happening to cause the problem. It's worse when I don't understand what it is that I need to understand. I have to admit to berating the perpetrator after I've traced the source of the problem. For some reason, I don't take it personally when I'm berating myself. (Why is that? How more personal can you get? :-D )

                          1 Reply Last reply
                          0
                          • C code_junkie

                            If you wanted to teach a monkey how to code you wouldn't use C/C++. You'd use VB or C# ;P

                            K Offline
                            K Offline
                            KP Lee
                            wrote on last edited by
                            #66

                            code_junkie wrote:

                            If you wanted to teach a monkey how to code...

                            Is that right after it writes out the entire works of Shakespeare on a typewriter? Uhh, do you know what a typewriter is?

                            1 Reply Last reply
                            0
                            • E exegetor

                              Everybody hold on one minute and take a deep breath. True: the HoS is not for questions. So look closely at the title of this thread and the original post. Vasily did not ask a question, he told a story from long ago (C++ builder 6 came out in 2002) when he was "beginning to make some programs" and ended up hating C++. He was not asking for help, and he reasonably responded to unsolicited advice by reasserting his reasons for hating C++. You may not share or understand the bad taste the experience left in his mouth, but do not slam his competence (he was a beginner ten years ago, remember?) and drag him into a screaming match then bitch-slap him for getting frusterated. Get a GRIP. Now... I learned to program as a kid in the early 80's and was good at it until I tried to learn OOP and windows programming simultaneously without a teacher, using Borland OWL on Win3.1. With no internet. The documentation was...terse. My code was corrupting the bitmaps used for drawing the minimize/maximize/close buttons. My code crashed. Then my code crashed WINDOWS and dumped out to the command prompt. Not kidding. Bad taste in mouth. For Windows, lParam, wParam, C++, Borland, the whole mess. It was definately HoS experience. I still hate C++ on a deep emotional level that will not be mollified by any appeal to reason. Today I program command line apps in ANSI C and couldn't be happier.

                              S Offline
                              S Offline
                              SlingBlade
                              wrote on last edited by
                              #67

                              You're a good person! :-D

                              1 Reply Last reply
                              0
                              • L Lost User

                                Ahh, a Heisenbug :) Another good one is a race condition between threads where sometimes one and sometimes the other thread 'wins' the race.

                                At least artificial intelligence already is superior to natural stupidity

                                K Offline
                                K Offline
                                KP Lee
                                wrote on last edited by
                                #68

                                That “uncertainty” sure shows up in a lot of places. One time I didn't have an IDE, and I'm getting duplicates. Comb over the code, can't find the logic problem. Insert write statements. Problem disappears. I'd had this happen in the past and the problem reappeared when I took out the write statements. This time, the problem remained gone and has stayed gone since. It's frustrating I'll never know what caused the problem or exactly what I did that fixed it. When it reappeared that earlier time, I think it took a week to find the single line of code that was a problem, and about the 20'th time re-reading that line.

                                1 Reply Last reply
                                0
                                • L Lost User

                                  So, you're saying you can still "do" PL1? (Actually, it was PL/I; which I "did"). What you "did" and what you can "do" (expertly) today are two different things. While I may have been an "expert" 1401/7010 Autocoder at one time, mentioning it today is meaningless.

                                  K Offline
                                  K Offline
                                  krsmichael
                                  wrote on last edited by
                                  #69

                                  I would not be be able to code PL/I at the level I was doing it in the 80's. Although I still remember segments of PL/I, JCL and ISPF. I wrote channel drivers. I wrote an implementation of Kermit in PL/I. Yeah, I think I had it wired. Today, I'd have to get reacquainted with it again. I was definitely an expert and was made the IBM mainframe advisor for General Dynamics Western Division. As far as meaningless, I disagree. One of the strengths I bring to a job is the vast diversity of languages I've used. There is nothing new under the sun and I've reverted to ideas that I was exposed to, to implement "novel" things today. I am not familiar with Autocoder but I'm certain there were novel constructs that would be applicable to solving problems today. I started C++ with CFront on MPW. I've been with it to the present. However, it isn't a one tool fits all. I use other tools when they make sense. The aversion to the "I hate C++" post is due to the history of seeing this posted and then accepted as fact. I work for Qualcomm. I use C and C++ a lot. When I recruit at local technical colleges and the hardest thing they have had to develop with is Java, I find it hard to take the student's education seriously. I want to see students who know assembly. Not so that they can code in it, but to demonstrate they have some knowledge of what is going on underneath the covers. We want to know that the person has the ability to resolve issue not only at the software level, but at the hardware level as well. But to answer your question, I do a lot of things expertly. I've worked on many projects that has personally affected you or those around you.

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    There is nothing to hate about C++. C++ doesn't written for winning prize for "Standards". It came to solve real world problem and solving it very well, since long time.

                                    Happy Programming

                                    W Offline
                                    W Offline
                                    wcsystems
                                    wrote on last edited by
                                    #70

                                    As a C/C++ coder who started as a .NET coder, I hated C++ to start with. I can honestly say that over the last few years it has really grown on me. I am forced to agree that a well-done c++ application is a thing of beauty. I am still more productive using .Net though, as it generally requires less code to get stuff done.

                                    1 Reply Last reply
                                    0
                                    • V Vasily Tserekh

                                      I surely know what i am talking about, HOW TO CLEAN A CODE THAT YOU CANT DEBUG. and surely you have ever worked with c++ builder 6, c++ builder doesnt have a debug and release version it only has a single output, instead of giving new ideas you talk about how good you are and how ignorant i am. I will make it simple so your mind can understand!!! step one -you write code step two -you compile that code step tree your ide launches the .exe and you try it step four you test your program and i does just fine step five you go to the application folder and make double click on the executable step six the application show and erro message with no error at all now you get it, how CAN YOU ISOLATE THE PROBLEM and when you isolate it what will you do if you can trace what is wrong

                                      M Offline
                                      M Offline
                                      Member 8697068
                                      wrote on last edited by
                                      #71

                                      Your environment may be different when you run the debugger verses just launching the exe file. Check "PATH" when executing both. Also, as I use to do, kill the program with print statements. You can do a "binary search" with print statements. One at the beginning, one in the middle and one at the end of the program. See which one prints and move them around accordingly. THE OLE HACK ;P

                                      1 Reply Last reply
                                      0
                                      • V Vasily Tserekh

                                        I surely know what i am talking about, HOW TO CLEAN A CODE THAT YOU CANT DEBUG. and surely you have ever worked with c++ builder 6, c++ builder doesnt have a debug and release version it only has a single output, instead of giving new ideas you talk about how good you are and how ignorant i am. I will make it simple so your mind can understand!!! step one -you write code step two -you compile that code step tree your ide launches the .exe and you try it step four you test your program and i does just fine step five you go to the application folder and make double click on the executable step six the application show and erro message with no error at all now you get it, how CAN YOU ISOLATE THE PROBLEM and when you isolate it what will you do if you can trace what is wrong

                                        M Offline
                                        M Offline
                                        mandyedi
                                        wrote on last edited by
                                        #72

                                        Did you try compile your code with other IDE?

                                        1 Reply Last reply
                                        0
                                        • V Vasily Tserekh

                                          the ide was c++ builder 6

                                          S Offline
                                          S Offline
                                          StephenPhillips
                                          wrote on last edited by
                                          #73

                                          It's just as well you've had an error like this - hopefully if/when you fix it, you'll have a more structured method for debugging in the future. It is not a good idea to write code with the approach of build and run it hoping it works; you have no idea what could be going wrong under the surface. If I was faced with an empty error dialog, I think my approach would be as follows (Apologies in advance, I'm not familiar with C++ Builder 6)

                                          - Track down 'when' the error occurs. We know it happens as you open the program, so try building some more useful output into the program. It sounds like you're unable to debug line-by-line, so I'd try bringing up an output dialog each time something works properly - print some useful text to say what was done, etc. - Find the offending operation/function that is causing the issue. With the information you've provided, I'd keep an eye out for any file loading stuff that may be involved; perhaps your file loader can only handle absolute paths and it's being fed relative ones. - Replace the suspect code with a simple test - instead of trying to load a file, perhaps output a "Loading file [path+filename]" message. If it doesn't come up with the blank dialog anymore, you know which line causes the issue. I'm far more used to debugging by pressing F10 until it breaks in Visual Studio, so this is effectively a more long-winded approach to doing the same thing. - Fix the offending code. Naturally, you still need to be able to load the file; I'm unfamiliar with your program's requirements, but if it's plain C++ loading a data file (binary or text, usually) then you should have no problems using an input stream[^]. I can promise you that this definitely works, and won't give you blank error messages.

                                          If you find errors in your code, it shouldn't matter if you get nonsensical or unhelpful messages - that's often the flavour of the day when it comes to programming. You need to break it down into each step to find out what's wrong, which inherently helps you understand your own code (or other people's code) better. Happy hunting!

                                          Sometimes a fist in the face says more than a thousand honeyed words.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

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