Stupid me GCC'd right over my source

Posted on 2007-10-15
Last Modified: 2010-04-01
I compiled over the top of my source code and my backup is a day old.  Using GCC on Mac OSX 10.4, i.e.

gcc source.c -o source.c

Any idea how I can get my source back?
Question by:jchristn123
    LVL 24

    Expert Comment

    If you do have you code under some sort of revision control (I doub it) you can replace it with the last checkin. Otherwise you've to start from the backup

    LVL 53

    Accepted Solution

    Here's a few things to check (in order of "easiness") :

    1) Did you use a text editor that takes backups before modifying something (usually something like source.c~ or similar) ?

    2) I don't know what file system you use on your Mac OS, but look out for file recovery tools. If you haven't done too much on the disk since the loss, you might be able to recover the file.

    3) Just re-write it (assuming there's not too much code that is lost).

    4) If all else fails, you have the option of disassembling the object file (in your case source.c since that's what you saved it as). Depending on the level of optimizations, and debugging options, you can get quite a lot out of it. However, typically, you won't get the exact source.
    LVL 1

    Author Comment

    I re-wrote it, and learned a valuable lesson.  Use makefiles and make instead of GCC on the command line.  Thanks infinity

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
    This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
    The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now