This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Printf doesn't seem to use my Putchar

I added a putchar routine to my main program ... a call to my new
putchar works as expected

but a call to printf acts like it is still using the old putchar

what am I missing here?

Parents
  • I created the following simple program:

    #include <stdio.h>
    
    char putchar (char c)
    {
    return (c);
    }
    
    void main (void)
    {
    printf ("");
    
    while (1)
      {
      }
    }
    

    When I compiled and linked, the following input modules were included in the final output (from the .M51 file):

    INPUT MODULES INCLUDED:
      .\STARTUP.obj (?C_STARTUP)
      main.obj (MAIN)
      C:\KEIL\C51\LIB\C51S.LIB (PRINTF)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CLDPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CLDOPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CSTPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?PLDIIDATA)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CCASE)
    
    

    Note that the putchar function is NOT included from the library! If I change my example program to the following:

    #include <stdio.h>
    
    void main (void)
    {
    printf ("");
    
    while (1)
      {
      }
    }
    

    and I compile and link, I get the following:

    INPUT MODULES INCLUDED:
      .\STARTUP.obj (?C_STARTUP)
      main.obj (MAIN)
      C:\KEIL\C51\LIB\C51S.LIB (PRINTF)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CLDPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CLDOPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CSTPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?PLDIIDATA)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CCASE)
      C:\KEIL\C51\LIB\C51S.LIB (PUTCHAR)
    

    Now, note that PUTCHAR is included from the C51S.LIB library.

    This is what you should get when you compile and link. Try my examples if you don't get these results.

    Jon

Reply
  • I created the following simple program:

    #include <stdio.h>
    
    char putchar (char c)
    {
    return (c);
    }
    
    void main (void)
    {
    printf ("");
    
    while (1)
      {
      }
    }
    

    When I compiled and linked, the following input modules were included in the final output (from the .M51 file):

    INPUT MODULES INCLUDED:
      .\STARTUP.obj (?C_STARTUP)
      main.obj (MAIN)
      C:\KEIL\C51\LIB\C51S.LIB (PRINTF)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CLDPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CLDOPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CSTPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?PLDIIDATA)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CCASE)
    
    

    Note that the putchar function is NOT included from the library! If I change my example program to the following:

    #include <stdio.h>
    
    void main (void)
    {
    printf ("");
    
    while (1)
      {
      }
    }
    

    and I compile and link, I get the following:

    INPUT MODULES INCLUDED:
      .\STARTUP.obj (?C_STARTUP)
      main.obj (MAIN)
      C:\KEIL\C51\LIB\C51S.LIB (PRINTF)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CLDPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CLDOPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CSTPTR)
      C:\KEIL\C51\LIB\C51S.LIB (?C?PLDIIDATA)
      C:\KEIL\C51\LIB\C51S.LIB (?C?CCASE)
      C:\KEIL\C51\LIB\C51S.LIB (PUTCHAR)
    

    Now, note that PUTCHAR is included from the C51S.LIB library.

    This is what you should get when you compile and link. Try my examples if you don't get these results.

    Jon

Children