Like Tree3Likes

I changed my code and recompiled with gcc/makefile, but nothing changed???

This is a discussion on I changed my code and recompiled with gcc/makefile, but nothing changed??? within the C Programming forums, part of the General Programming Boards category; I tried editing other lines of code too, I just open vi, modify a print statement, and recompile (first deleting ...

  1. #16
    Registered User
    Join Date
    Jun 2011
    Posts
    78
    I tried editing other lines of code too, I just open vi, modify a print statement, and recompile (first deleting all .o and .exe of course). When I run it, the program fails to run its functions properly, and the print statement has not been changed. Then I simply type script, and suddenly everything runs perfectly and the printf statement is displayed properly. Then I exit the script, and once again the program misfires and displays the old print statement which has clearly been changed in vi.

    This is the same problem I was having a few days ago, where all I was trying to do was create a simple helloworld app. It is apparently saving an old version of the code/executable and running that incorrectly (because it doesn't execute the old code properly at all) unless script is running, in which case it runs the new version correctly (in which only a single printf has been modified, and so there is no reason that the previous version wouldn't run properly as well).

    I just can't imagine how this is happening when I am not recompiling anything, and all I am doing is turning script on and off.

    One thing I noticed is that I have to exit script -twice-. The first time it says "There are stopped jobs." I don't know what that means but perhaps that is a clue.

  2. #17
    Registered User
    Join Date
    Jun 2011
    Posts
    78
    Ok, this really blows my mind, but it proves there are two different programs stored in memory, and which one is called depends on whether or not script is active - I deleted everything in the folder, and the program STILL runs! It only fails to run if I call script, and then it acts as it should, because there is nothing to run. If I then disable script, the old program once again is called, and it runs albeit incorrectly and with old code.

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Can you type "which c"? I can't imagine that you might have gotten some earlier version of your program installed in /usr/bin or somewhere in your path, but you never know.

  4. #19
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,557
    Stop messing about with script and job suspension. That's where your trouble lies.

    script basically opens up a shell within a shell. You can open script session while you have stopped jobs, but it won't let you exit the shell it created if you have stopped jobs. The instance of your chess program you started before you started your script session will be the one in memory before you made the changes, thus you wont see the changes when you return to the "outer" shell. You probably either ran the command with an & at the end, like "chess &" and put it in the background, or you hit ctrl-z to pause the job at some point. Either way, I think you have a giant clusterf--- of jobs and script sessions (hence my item #1 and 2 from post 13).

    Type "jobs" at the terminal and see what comes up. It might be something like
    Code:
    $ jobs
    [1]+  Stopped                 ./a.out
    Kill all of those. You kill by job number (the thing in [ ]), like so "kill %1". That kills job #1. Do that for all jobs, then exit that script with "exit" or ctrl-d. Keep doing this until all of your terminals close down and you're sitting at an empty desktop or login screen. Log in again in one terminal only. Do a "ps -f" to make sure you don't have any instances of your chess program running (you shouldn't if you actually logged out of all your shells/terminals). Your output should look similar to this:
    Code:
    $ ps -fu username
    UID        PID  PPID  C STIME TTY          TIME CMD
    username  4582  4581  0 17:17 pts/4    00:00:00 bash -i
    username  4649  4582  0 17:26 pts/4    00:00:00 ps -fu username
    Then, clean everything up, make your change, compile and run. Change it back, clean up, compile run. You should see the two different versions as you expect.
    Last edited by anduril462; 06-23-2011 at 06:31 PM.

  5. #20
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Adam Rinkleff View Post
    Ok, this really blows my mind, but it proves there are two different programs stored in memory, and which one is called depends on whether or not script is active - I deleted everything in the folder, and the program STILL runs! It only fails to run if I call script, and then it acts as it should, because there is nothing to run. If I then disable script, the old program once again is called, and it runs albeit incorrectly and with old code.
    You don't by chance have a "debug" and "release" folder in there do you? You can wipe out the release folder as often as you like and it won't work for crap if the IDE is launching the debug version...

  6. #21
    Registered User
    Join Date
    Jun 2011
    Posts
    78
    Quote Originally Posted by anduril462 View Post
    or you hit ctrl-z to pause the job at some point.
    Oooh... I thought ctrl-z exited? How do I exit then? I think you are right about the shell within a shell, at least its not a ghost within a shell. hah. hah.



    ........oh, ctrl-c, i always thought that was reserved for copying things.
    Last edited by Adam Rinkleff; 06-23-2011 at 09:54 PM.

  7. #22
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    Quote Originally Posted by Adam Rinkleff View Post
    Oooh... I thought ctrl-z exited? How do I exit then? I think you are right about the shell within a shell, at least its not a ghost within a shell. hah. hah.
    Nah ctrl-z pauses the process. Notice how it says "stopped" if you type jobs.
    Also, in addition to killing them you can resume the process(es) either in the background with 'bg <num>' or in the foreground with 'fg <num>'
    And yeah, ctrl-c usually means copy in GUI apps. But in console apps it means abort unless you explicitly override it to do something else.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Still get error even if i changed a lot..
    By icefire99 in forum C++ Programming
    Replies: 9
    Last Post: 04-26-2007, 03:31 AM
  2. Website changed...
    By funkydude9 in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-04-2003, 10:44 PM
  3. How times have changed
    By golfinguy4 in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 12-21-2002, 11:25 PM
  4. Not much has changed in four years...
    By Eibro in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-18-2002, 08:11 PM
  5. How has this array been changed?
    By Agha in forum C Programming
    Replies: 4
    Last Post: 04-09-2002, 10:43 AM

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