Thread: Segmentations and casting errors

  1. #1
    Registered User
    Join Date
    Jul 2008
    The Netherlands

    Segmentations and casting errors

    At times I run into segmentations and casting errors (I do realize both are different kind of errors).

    Mostly I solve them, but it takes me a lot of time to do so. I wondered is there a guide or way of approach to solve this kind of errors more quickly and in a logical way? Or is it just.... you have them, deal with them!!! .

    /off topic on
    ps. Do we have here also an forum where I can ask questions about VI and GDE?
    /off topic off

    Thanks in advance,

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    You mean segmentation fault? These are usually easy to find with a debugger. Just look back at the stack and figure out why the value is incorrect.

    Not sure what you mean by casting errors, so not sure what to do about them - the only errors I know of with regards to casting is source errors, and compiler errors are always the easiest to find (in comparison to errors not detected by the compiler - sometimes compiler errors can be a bit difficult too) - not to mention that you should avoid casts as much as possible anyways.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Don't write them in the first place, and compile as you go. Rather than writing a huge program with 50 zillion errors which you have to fix all at once.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    By "casting errors" do you mean using the wrong format specifiers for printf()? That's a reasonably common mistake.

    gcc will warn you about this if you enable warnings.
    gcc -W -Wall program.c -o program

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed