Segmentations and casting errors

This is a discussion on Segmentations and casting errors within the C Programming forums, part of the General Programming Boards category; At times I run into segmentations and casting errors (I do realize both are different kind of errors). Mostly I ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Location
    The Netherlands
    Posts
    3

    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,
    Joke.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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.

    --
    Mats
    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
    Location
    Australia
    Posts
    3,459
    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
    Location
    Canada
    Posts
    8,046
    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.
    Code:
    gcc -W -Wall program.c -o program
    dwk

    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: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21