Thread: some weird warnings

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    some weird warnings

    Ok does anyone no why im getting these errors
    gjc.c:72: warning: passing arg 1 of `fopen' makes pointer from integer without a cast
    gjc.c:77: warning: format argument is not a pointer (arg 2)
    gjc.c:82: warning: passing arg 1 of `fopen' makes pointer from integer without a cast
    gjc.c:87: warning: format argument is not a pointer (arg 2)

    And could someone double check my makefile just in case iv done it wrong please?

    Code:
    #include "gjc.h"
    #include "gjc_options.h"
    #include "gjc_utility.h"
    
    int main(int argc, char* argv[])
    {
       GJCType menu;
      
       
       
      
    
       return EXIT_SUCCESS;
    }
    
    int commandLineArguments(int argc, char *argv)
    {
        /* declaration of variables*/
        
        
        /* declare file pointers to files*/
        FILE *menu;
        FILE *submenu;
        
        
       /* command line argument*/
       
       /* checks to see if 3 command line arguments have been entered*/
       if(argc<3)
       {
         
         printf("Invalid: Enter 3 command line arguments (Error:)\n");
         exit(ERRORCODE);
       }
       else if(argc >3)
       {
         printf("Too many arguments where supplied\n");
         return ERRORCODE;
       }
       
       
       
       /* check to see if the proper .dat names have been passed*/
       
       
       
      /* if(argc==3 && !strcmp(argv[1], "menu"))
       {
         printf("Cannot find filename wrongly entered\n");
         return ERRORCODE;
       }*/
      
       /*
       if(argc==3 && !strcmp(argv[2], "submenu"))
       {
         printf("Cannot find filename\n");
         return ERRORCODE;
       }*/
       
       /* opening the menu.dat file for reading*/
       menu = fopen(argv[1], "r");
       
       /* check to see if the file exists*/
       if(menu ==NULL)
       {
          printf("Im sorry %s does not exit(ERROR!)\n", argv[1]);
          return ERRORCODE; /* cannot proceed*/
       }
       
       /* opening the submenu file for reading*/
       submenu = fopen(argv[2], "r");
       
       /* check to see if the subMenu file exists*/
       if(submenu ==NULL)
       {
          printf("The file %s does not EXIST(ERROR!)\n", argv[2]);
          return ERRORCODE; /* cannot proceed*/
       }
       
       return EXIT_SUCCESS;
    
    }

    makefile
    Code:
    all: gjc.o gjc_utility.o gjc_options.o
    	gcc -gstabs -o gjc gjc.o gjc_utility.o gjc_options.o
    	
    gjc.o: gjc.c gjc.h
    	gcc -gstabs -Wall -ansi -pedantic -c gjc.c
    	
    gjc_options.o: gjc_options.c gjc_options.h
    	gcc -gstabs -Wall -ansi -pedantic -c gjc_options.c
    	
    gjc_utility.o: gjc_utility.c gjc_utility.h
    	gcc -gstabs -Wall -ansi -pedantic -c gjc_utility.c
    	
    clean:
    	rm gjc gjc.o gjc_options.o gjc_utility.o

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Ok does anyone no why im getting these errors

    in commandLineArguments you declared argv as an array of char.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Code:
    int commandLineArguments(int argc, char *argv)
    int commandLineArguments(int argc, char *argv[])

  4. #4
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252
    i changed it to

    int commandLineArguments(int argc, char *argv[])

    and now i get error conflicting types for command line arguments

    previous declaration of command line arguments


    is my makefile correct that could be the problem possibly mayb its not compiling properly?

  5. #5
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    You probably have your function prototype of int commandLineArguments(int argc, char *argv) conflicting.

  6. #6
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252
    int commandLineArguments(int argc, char *argv) when i leave it like this i get

    gjc.c:72: warning: passing arg 1 of `fopen' makes pointer from integer without a cast
    gjc.c:77: warning: format argument is not a pointer (arg 2)
    gjc.c:82: warning: passing arg 1 of `fopen' makes pointer from integer without a cast
    gjc.c:87: warning: format argument is not a pointer (arg 2)


    when i do this
    int commandLineArguments(int argc, char *argv[])
    thats when i get the conflicting errors

  7. #7
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    I know. I said your declaration probably differs from the prototype at the top of the file or in some header.

  8. #8
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252
    yup u where correct sorry that was a bad mistake

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Warnings when using vector of vector
    By Boksha in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2008, 01:54 PM
  2. Compilers and warnings
    By rogster001 in forum C Programming
    Replies: 6
    Last Post: 03-26-2008, 05:16 AM
  3. Replies: 9
    Last Post: 03-14-2008, 09:55 AM
  4. Warnings from String manipulation functions.
    By Arker in forum C Programming
    Replies: 4
    Last Post: 10-14-2002, 11:59 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM