Thread: perror undefined?

  1. #1
    Registered User
    Join Date
    Jan 2012
    Location
    Norwich, Norfolk, United Kingdom
    Posts
    3

    perror undefined?

    I am attempting to compile some old code - it is in both C and F, and keeps falling over when I try to create .obj files in cMbedded visual C++ v 4;

    warning C4013: 'perror' undefined; assuming extern returning int

    Code:
    #include "soilwater.h"
    #include <stdlib.h>
    #include <stdio.h>
    
        void initsite(char *sitename, SITEPAR_SPT sitepar, LAYERPAR_SPT layers,
                      FLAG_SPT flags)
        {
    
          int  imo, m;
          char inptline[INPTSTRLEN];
          char errmsg[INPTSTRLEN];
          FILE *fp_in;
    
          if (flags->debug) {
            printf("Entering function initsite\n");
          }
    
          if ((fp_in = fopen(sitename, "r")) == NULL) {
            sprintf(errmsg, "Cannot open file %s\n", sitename);
            perror(errmsg);
            exit(1);
          }

    I don't know if there is an error in the code or if an appropriate libry is missing? any help gratefully appreciated
    Amy

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    "embedded" doesn't sound like it has a console to print errros to. Are you sure you want to run this program on Windows CE?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Jan 2012
    Location
    Norwich, Norfolk, United Kingdom
    Posts
    3
    For compiling, I was recommended Microsoft Visual C++ version 4.0 and Microsoft Fortran PowerStation version 4.0 by the people who produced the code, so I presume that I am using the appropriate compiler, the executable will be run from command prompt, so will be able to print error there- should I be doing something with the compiler settings for that? Hopefully this answers your questions, I am very new to code, and still trying to get to grips with the terminology
    Thanks

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    You need to be very precise with terminology when dealing with computers. Computers do exactly what you say, so if you don't say exactly what to do, they will produce garbage.

    You said in your first post that you use "Microsoft® eMbedded Visual C++ 4.0". This is for developing Windows CE (old phone operating system) programs. Do you really intent to get an executable that will run on old windows phones? My guess is that you were told to use "Microsoft Visual C++ 4.0". You googled and found the embedded thing. Why? Because that thing you were recommended is from the stone age. And I mean it. It was for Windows 95. I started out programming with 5.0 which was 18 years ago and it came on floppy discs. Floppy discs for gods sake. I'm not sure if you will get your mammoth hunting app to run today, but your best bet might be to install a recent compiler, for example Microsoft Visual Studio 2010. The "Express" Editions are free.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Jan 2012
    Location
    Norwich, Norfolk, United Kingdom
    Posts
    3
    fixed by adding

    void perror(const char *message);

    to code- my stdio.h file is empty!

    although I still don't know if it will run- any advice on where to download the real mammoth hunting compiler would be great, but yes- every link I found to it was talking about which floppy disk to do what with- even the embedded version I got requires a version of windows so old I had to dust off an old computer (which does actually have a floppy drive, although I'm not sure its wired in anymore)
    anyway, I will give Microsoft Visual Studio 2010 a go if I can't get the .obj files to link, ta!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is this undefined?
    By carrotcake1029 in forum C Programming
    Replies: 3
    Last Post: 01-28-2009, 11:42 AM
  2. perror in C
    By vidya madala in forum C Programming
    Replies: 2
    Last Post: 11-11-2007, 08:40 AM
  3. Bad address when using stat() and perror()
    By tore- in forum C Programming
    Replies: 3
    Last Post: 05-23-2007, 10:26 AM
  4. errno --perror() problem
    By GanglyLamb in forum C Programming
    Replies: 10
    Last Post: 04-01-2003, 02:01 PM
  5. perror
    By C_Coder in forum C Programming
    Replies: 2
    Last Post: 11-11-2001, 10:45 AM

Tags for this Thread