redefining stdout/stderr

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #1

    redefining stdout/stderr

    when I declare

    #ifndef stdout
    #define stdout 0
    #endif

    #ifndef FILE
    #define FILE void
    #endif

    it gives me warning as "redefined in stdlib.h".
    How can I prevent #include<stdio. h> or #include<stdlib .h>
    for particular translation unit?
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    this is how stdout is define.
    Code:
    #ifndef _STDSTREAM_DEFINED
    #define stdin  (&__iob_func()[0])
    #define stdout (&__iob_func()[1])
    #define stderr (&__iob_func()[2])
    #define _STDSTREAM_DEFINED
    #endif
    if you set stdout to zeor your application will fail if you use printf function or scanf function or any function that print on standard output. It does not warn me? why?

    Comment

    • ashitpro
      Recognized Expert Contributor
      • Aug 2007
      • 542

      #3
      I think I solved my problem by re-arranging the headers. By the way, my code can not be dependent on c-runtime. someone else will plugin their platform specific code. The reason, I was suppressing those "#defines" is that particular code is auto-generated by lex.

      Comment

      Working...