Syntax problem or Makefile Problem

This is a discussion on Syntax problem or Makefile Problem within the C Programming forums, part of the General Programming Boards category; Hi, I have a problem referencing a function in another file. I get the below error and wonder if anyone ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    3

    Syntax problem or Makefile Problem

    Hi,

    I have a problem referencing a function in another file. I get the below error and wonder if anyone has any ideas:

    Code:
    MYprog.c: In function `main':
    MYprog.c:33: warning: implicit declaration of function `MYFW_SendInform'
    MYprog.c:33: error: called object is not a function

    I have the following files The intention is that MYFW becomes a libray accessible to a number of developments...
    MYFW.h/MYFW.c: A collection of constants and functions that provide common processing tasks
    MYprog.h, MYprog.c: The collection of functions to perform the specific tasks in hand.

    Code:
    #MYFW.h
    # A header file for the FRAMEWORK.
    
    #ifndef _MYFW_H
    #define _MYFW_H
    
    #define MYFWinform \
        (void)MYFW_SendInform(__FILE__, __LINE__, "INFORM")
    
    #endif
    Code:
    MYFW.c
    # the source code for the FRAMEWORK.
    
    #include <MYFW.h>
    
    PUBLIC void MYFW_SendInform  (IN char  *pcSourceFile,
                                                       IN int   iSourceLine,
                                                       IN char  *pcMessType)
    {
        // I know I'n not using the params, want to get it working first.
         printf("MYFW_SendInform: in\n");
    }

    Code:
    #MYprog.h
    # A header file for the DEVELOPMENT.
    
    #ifndef MYPROG_H
    #define MYPROG_H
    
    #include <MYFW.h>
    
    #endif
    Code:
    #MYprog.c
    # The source for the the DEVELOPMENT.
    
    #include "MYprog.h"
    
    int main(int argc, char **argv)
    {
        MYFWinform("main: in");
        exit(0);
    }
    So the MyProg.c includes MYprog.h
    MYFW.c includes MYFW.h
    and MYProg.h includes MYFW.h.

    Is there something wrong with the syntax, the way I've linked the files or is this a problem with the makefile? Should I be compiling the MYFW as an object first? Here is my makefile.....

    Code:
    # makefile
    OBJDIR=../OBJ
    BINDIR=../../bin
    CC=gcc
    CFLAGS=-I. -g -Wall
    EXE=MYProg
    INC=MYFW.h MYProg.h
    SRC=MYFW.c MYProg.c
    
    ${OBJDIR}/%.o: %.c ${INC}
        ${CC} -c -o $@ $< ${CFLAGS}
    
    MYProg: ${OBJ}
        ${CC} -o ${BINDIR}/${EXE} ${OBJ} ${CFLAGS}

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,249
    There is no visible prototype of MYFW_SendInform. This:

    Code:
    PUBLIC void MYFW_SendInform  (IN char  *pcSourceFile,
                                                       IN int   iSourceLine,
                                                       IN char  *pcMessType);
    Needs to be declared in MYFW.h
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    3
    Quote Originally Posted by brewbuck View Post
    There is no visible prototype of MYFW_SendInform. This:

    Code:
    PUBLIC void MYFW_SendInform  (IN char  *pcSourceFile,
                                                       IN int   iSourceLine,
                                                       IN char  *pcMessType);
    Needs to be declared in MYFW.h
    Thanks.. so obvious.. been looking at the code to long I think. Put it in but I have another error stating:
    Code:
    MYProg.c:33: error: void value not ignored as it ought to be
    BTW, just for clarity.. the PUBLIC is a define in the MYFW.h file..

    Code:
    #define PUBLIC 
    #define PRIVATE static
    This suggests that the MYFW_SendInform function is returning something, but it isn't. All that happens in it is a printf.

    Anyone any ideas?

    Thanks

    Mike

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. makefile problem
    By allelopath in forum C Programming
    Replies: 4
    Last Post: 06-06-2005, 01:22 AM
  5. syntax linked list problem & struct problem
    By beely in forum C Programming
    Replies: 5
    Last Post: 11-11-2002, 08:14 AM

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