Thread: A simple problem involving prototype function declarations (I hope)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    1

    A simple problem involving prototype function declarations (I hope)

    The problem is a simple Go-Back-N protocol, the culprit function was provided by the teacher and I am not allowed to change it:

    Start line = 516
    Code:
    starttimer(int AorB, float increment)  /* A or B is trying to start timer */
    {
    
     struct event *q;
     struct event *evptr;
    
     if (TRACE>2)
        printf("          START TIMER: starting timer at %f\n",time);
     /* be nice: check to see if timer is already started, if so, then  warn */
    /* for (q=evlist; q!=NULL && q->next!=NULL; q = q->next)  */
       for (q=evlist; q!=NULL ; q = q->next)  
        if ( (q->evtype==TIMER_INTERRUPT  && q->eventity==AorB) ) { 
          printf("Warning: attempt to start a timer that is already started\n");
          return;
          }
     
    /* create future event for when timer goes off */
       evptr = (struct event *)malloc(sizeof(struct event));
       evptr->evtime =  time + increment;
       evptr->evtype =  TIMER_INTERRUPT;
       evptr->eventity = AorB;
       insertevent(evptr);
    }
    Line = 81
    which when I call
    Code:
    starttimer(0, 50.0);
    gives the following errors:
    517 C:\Dev-Cpp\Free\prog2.c conflicting types for 'starttimer'
    517 C:\Dev-Cpp\Free\prog2.c an argument type that has a default promotion can't match an empty parameter name list declaration
    81 C:\Dev-Cpp\Free\prog2.c previous implicit declaration of 'starttimer' was here

    I manged to find this trifecta of errors several places on the internet and the general consensus was that it came from trying to call the function before it declaration (makes sense) with the proposed solution of adding a prototype declaration of that function before the function gets called. So I did this:

    Line 38
    Code:
    starttimer(int AorB, float increment);
    Which seems to fix the original errors but generates me this shiny new error:

    38 C:\Dev-Cpp\Free\prog2.c [Warning] data definition has no type or storage class

    Which I can't find anything to in my scouring of the internet and it basically just has me at a loss. I tried declaring it void, I tried different variable names, passing no variables, moving it around a bit but nothing.

    If anyone could help I would be forever grateful, I'd have your children but alas no uterus.

    Please Help
    Last edited by Aspect; 04-21-2009 at 06:54 PM. Reason: typos

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM