Thread: [Error] Id returned 1 exit status

  1. #1
    Registered User
    Join Date
    Jul 2016
    Posts
    9

    [Error] Id returned 1 exit status

    I keep getting this "[Error] Id returned 1 exit status" when I'm using some specific functions and I can't figure out why. Here's the last piece of code that's been giving me this error.

    Code:
    #include <stdio.h>
    #include <malloc.h>
    
    main(){
        printf("Memory available: %u\n", _memavl());
    }
    It also says "Undefined reference to memavl" It's probably something simple and I'm missing it. It also gave me something like this when I tried using "cprintf" too. I tried checking to see if the program is running on the background and it's not. Thanks for your help.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,630
    Where have you implemented the function?

    Jim

  3. #3
    Registered User
    Join Date
    Jul 2016
    Posts
    9
    That's the whole code, actually. I included the header file and tried to use it in main block of my program. I'm a beginner so I'm just testing functions to figure out how they work. It also crashes when I try:

    Code:
    #include <stdio.h>#include <malloc.h>
    main(){
        char *x="Testing";
        printf("%u",_msize(x));
    }
    I don't know if it's related.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,675
    Which compiler are you using?

    Because those functions typically belong in the 16-bit DOS world, which became pretty much obsolete 25+ years ago.

    If you're reading a book with this stuff in, you need a better book.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jul 2016
    Posts
    9
    I'm using Dev C++ and yes, you are right. I found this old book that was published in 1991 and I thought it would be a good idea to start learning how to code in C. Are there better functions to get the amount of the available memory today?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,675
    Most systems you're likely to work on implement virtual memory.

    Your operating system is in charge of the real memory, and tells each user program that there is 2GB (for example) available. Very few programs will use anything but a fraction of that, so the OS just divides up the real RAM as to what each program actually needs.

    Of course, if several greedy programs are run at the same time, the amount of memory needed by all programs exceeds real RAM. At this point, the OS will swap some of the memory to the swap file.

    You should study modern OS architectures for all the details of how this actually works in practice.


    Oh, and if you're referring to the "Bloodshed" version of Dev-C++, then that too is hopelessly out of date.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Jul 2016
    Posts
    9
    God... I guess this is the worst part of trying to teach these things to yourself alone. Thanks for the replies. I'll look it up on the internet to get more info about memory usage and try to find out a less outdated compilers and sources.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 01-09-2016, 12:24 AM
  2. collect2.exe: error: ld returned 1 exit status
    By umutefiloglu in forum C Programming
    Replies: 4
    Last Post: 05-11-2014, 09:37 AM
  3. collect2: ld returned 1 exit status error??
    By blindchicken11 in forum C Programming
    Replies: 11
    Last Post: 11-07-2011, 08:38 PM
  4. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  5. ERROR collect2: ld returned 1 exit status
    By meili100 in forum C++ Programming
    Replies: 13
    Last Post: 12-04-2007, 12:20 PM

Tags for this Thread