Memory tracking library from C Unleashed,,,some problems...

This is a discussion on Memory tracking library from C Unleashed,,,some problems... within the C Programming forums, part of the General Programming Boards category; Hi, Attached are the source files of the memory tracking library and a simple driver program to test the library. ...

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Memory tracking library from C Unleashed,,,some problems...

    Hi,

    Attached are the source files of the memory tracking library and a simple driver program to test the library. But i can't get it to work. I have to define 'MEMTRACK' in order for the memory tracking functions to operate. But after i type 'define MEMTRACK' in the source of the driver program, nothing happened. It's supposed to output a report as a text file, but it didn't.

    Pls just download the files and have a run, and tell me if i've doen anything wrong.

    thnx in advance
    Attached Files Attached Files

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,762
    Seems OK to me

    > 'define MEMTRACK'
    No, you have an #ifdef MEMTRACK

    You need to define the symbol on the command line, depending on whether you want (or not) the traced memory routines.

    This is my command line
    gcc -DMEMTRACK memtrack.c memtrkmn.c

    And here are the results.
    Attached Files Attached Files

  3. #3
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    I use DEVC++ 4 and i went into compiler options and at the 'add the following commands' i try a combination of -DMEMTRACK but nothing works and instead generates errors while compiling. Erros of undefined reference to the mem track functions.

    What did i do wrong?

    thx again
    Last edited by Nutshell; 04-17-2002 at 08:27 PM.

  4. #4
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    Pls tell me how to define stuff in order for them to compile, now i can't try out any of the programs from my book's cd rom.

    thnx

  5. #5
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    attached is another program i can't compile. HOW DO I DEFINE???????????? It's got all sorts of undefined reference to such and such ( which are all the functions ).........

    pls help

    thnx
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    The code appears to be fine; it compiled under gcc without warnings (which is pretty encouraging, since it's clearly not coded for linux).

    Undefined references to functions are a linker problem. You are probably trying to compile main.c on its own, but you need to do the two together.

    Let us know what compiler you use, and if possible, what the command line argument you pass to it is (if your IDE handles that, let us know what IDE you're using).
    Callou collei we'll code the way
    Of prime numbers and pings!

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,762
    > 'add the following commands'
    Mmm, I'm not familiar with DEV-C++, but it is a gcc derivative

    The place where you want to add the -DMEMTRACK should be in the compiler 'command line options'.

    And please post some exact error messages.

    Also, are you including ALL your .c files in the project?

  8. #8
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    I included all ( 2 total ) the .c files in y devC++ project but when i compile it i got whole bunch of the following errror:


    memtrkmn.c
    ANSI C++ forbids implicit conversion from `void *' in assignment


    any ideas?

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Yep. Stop compiling a C++ and compile as C. (Don't have files named .cpp either.)

    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    all my filenames are .c but i 'think' i'm compiling as C.

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    If it's telling you that 'ANSI C++ forbids...' then it isn't compiling as C. What you have is something like this:

    char *c;
    c = malloc( 200 );

    If you compile that as C it's valid. For it to compile as C++ without any errors, you have to do:

    char *c;
    c = (char *)malloc( 200 );

    C++ requires a type cast on void pointers. This is the error you're getting, which tells us you're compiling as C++.

    Quzah.
    Hope is the first step on the road to disappointment.

  12. #12
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    Hi sorry i selected the wrong option.

    I successsfully compiled it but when it executes it's suppose to output a file name memtrack.txt. But instead nothing happened. Nothing outputed to the stdout and no files created.

    Any ideas? please give a hand.

    thnx a lot

  13. #13
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    wait i got it workin.

    In my DevC++-> tools and compiler options, i go to compiler commands and type -DMEMTRACK.

    One last question. DevC++ doesn't come with documentation teaching stuff like above "-DMEMTRACK" for example. Where can find documentation on using those special commands command-line options?

    thnx in advance
    Last edited by Nutshell; 04-19-2002 at 03:28 AM.

  14. #14
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,762

  15. #15
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    found thnx...


    at first i was trying to find -D, but on the page it was actualy displayed as -DMARCO

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

Similar Threads

  1. Problems with shared memory shmdt() shmctl()
    By Jcarroll in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 11:48 PM
  2. problems with memory allocation
    By Waldo2k2 in forum C++ Programming
    Replies: 12
    Last Post: 07-16-2002, 02:08 PM
  3. Library file problems
    By beila00 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 03:47 PM
  4. Memory Allocation/Freeing Problems
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 05-29-2002, 09:50 AM
  5. Ascii conversion problems with dynamic memory
    By Butters in forum C++ Programming
    Replies: 2
    Last Post: 01-29-2002, 12:22 PM

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