Thread: Pelles C

  1. #1
    zach
    Guest

    Pelles C

    I found that if you work with Pelles C, and you initialize a variable within a switch statement, Pelles signals an error (and blocks you from further working) and you will not be unable to find out why, unless by sheer chance or insane searching. (I will inoculate this statement by adding: of course the wizards already knew this.)
    Last edited by zach; 09-07-2019 at 07:48 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What's a switch loop?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    zach
    Guest
    I didn't know a better expression - you tell me.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I can't tell you because I don't know what it is. Were you trying to combine a switch statement and a loop in some way that Pelles C saw as a syntax error? Perhaps an example of what you were trying to do that Pelles C flagged as an error would help.

    EDIT:
    For combining a switch statement with a loop, the most famous example that comes to mind is Duff's device, though I doubt that was what you were going for since you mentioned initialising a variable.
    Last edited by laserlight; 09-07-2019 at 07:50 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    zach
    Guest
    Quote Originally Posted by laserlight View Post
    I can't tell you because I don't know what it is. Were you trying to combine a switch statement and a loop in some way that Pelles C saw as a syntax error? Perhaps an example of what you were trying to do that Pelles C flagged as an error would help.

    EDIT:
    For combining a switch statement with a loop, the most famous example that comes to mind is Duff's device, though I doubt that was what you were going for since you mentioned initialising a variable.
    No no no combinations, loops or whatever, I wrote < within >.

    switch (expression)
    {
    case 1: // some code. If in *that* code one initializes a variable, e.g., char banans[no] then you create an error that is fiendishly hard to find.
    Last edited by zach; 09-07-2019 at 08:02 AM.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Ah. Well, that's easily solved by introducing a code block labelled by the case 1 to avoid issues like control skipping variable initialisation. But I'm curious about the hard to find thing. What was the exact error message?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    zach
    Guest
    There was NO error message - simply complete fail of the compilation. There was NO reference to an ERROR LINE, which most often in Pelles there is not. However one is generally even directed to lines that have nothing to do with the error at all! In general the error messaging of Pelles is a dead loss. What I regularly do is transfer the code to DEFC and see what that compiler has to say. But in this case DEFC didn't have a problem with the code in question at all. Notwithstanding these shortcomings Pelles C has a beautiful interface (visual code processor).

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by zach
    However one is generally even directed to lines that have nothing to do with the error at all!
    As you may know, the error message line generally refers to where the error was detected, not where the mistake was made, so this in itself is not a surprise. But if you find that other compilers are able to diagnose the mistake more accurately, then it could mean that Pelles C is a relatively poor compiler in this respect, and so you may wish to switch to another compiler until you're proficient in C.

    Quote Originally Posted by zach
    There was NO error message - simply complete fail of the compilation.
    That doesn't sound right. I'd suggest coming up with a small and simple program that demonstrates this, then posting in a Pelles C forum/mailing list to ask for help in getting an error message. If the answer is that the lack of an error message is to be expected, then yes, ditch Pelles C until you are proficient in C.

    Quote Originally Posted by zach
    Notwithstanding these shortcomings Pelles C has a beautiful interface (visual code processor).
    You may be able to configure the Pelles C IDE to work with another compiler. If that's not possible, honestly, there are plenty of beautiful IDEs out there.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    zach
    Guest
    "You may be able to configure the Pelles C IDE to work with another compiler. If that's not possible, honestly, there are plenty of beautiful IDEs out there." Where the mistake was made / versus where the error was detected. In the past I did a lot of IT work, never have I met with such rubbish as the Pelles error reporting. (I am log retired and decided to have a go with C as an alternative to the geraniums.) Would you please let me have your advice as to a good C IDE free download that isn't a hell of a job to install?

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by zach
    Would you please let me have your advice as to a good C IDE free download that isn't a hell of a job to install?
    That depends on your OS. I'm using the cross platform Geany, but it's a lightweight IDE such that I mainly use it as an editor and compile on the command line. Code Blocks, also cross platform, seems okay for a full IDE and has a package that includes gcc for Windows. Visual Studio Code is another cross platform editor that is practically a lightweight IDE, but configuring it for C might take a bit of work because the extension doesn't seem fully fledged... but then it does have a nice visual interface.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Registered User
    Join Date
    Jul 2002
    Posts
    33
    Quote Originally Posted by zach View Post
    Would you please let me have your advice as to a good C IDE free download that isn't a hell of a job to install?
    I would recommend code:blocks. It runs on windows and linux and you can debug your code in the ide.

  12. #12
    zach
    Guest
    Roemccarr: Hi, thank you for responding. I didn't want to switch IDEs before finishing my current project. Which I have now done, with the excellent help of you all. I will now try code blocks.
    Last edited by zach; 09-09-2019 at 10:49 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging In Pelles C Plz Help
    By Anitrex in forum C Programming
    Replies: 47
    Last Post: 12-30-2011, 02:13 AM
  2. Compiling C++ on Pelles C....
    By CommonTater in forum C++ Programming
    Replies: 2
    Last Post: 05-27-2011, 07:56 PM
  3. Pelles C Temperature
    By uneasybbj in forum C Programming
    Replies: 4
    Last Post: 11-23-2010, 01:51 PM
  4. help debugging in Pelles C IDE
    By gaurav9991 in forum C Programming
    Replies: 3
    Last Post: 10-30-2010, 07:15 AM
  5. Opinion on C99 ver. of Pelles C IDE?
    By Adak in forum C Programming
    Replies: 0
    Last Post: 03-13-2009, 07:27 PM

Tags for this Thread