about "far pointer (implicitly) casted by near pointer"

about "far pointer (implicitly) casted by near pointer"

  • I've got this warning for this code :


    char * NextApostrophe(char far
    *addr){  
    //apostrophe=> "


       
    addr=strchr(addr, 0x22);


      return addr;


    }

    it says : [Warning(ccom)] far pointer (implicitly) casted by
    near pointer




    I've read this document:



    documentation.renesas.com/eng/products/tool/rej10j1575_nc30_u.pdf


    tool-support.renesas.com/eng/toolnews/faq/faq.pdf


    and still doesn't understand what it means. Anybody have ever
    experienced like this ?


    Is there any way to get rid this warning messages ?



  • The function parameter addr is of type "char far *", the return
    type of the function is just "char *".  You
    are trying to return a value which does not match the function type
    which will generate a warning.


    If you need the far pointer, then the return type should be
    "char far*".  Otherwise, you could remove
    the "far" from the addr declaration.



  • wow, it works. Many thanks.




  • Hallo guys,


    I have a r32C StartKit and use the nc100 Compiler and
    High-performance Embedded Workshop.


    I have another question abaut far pointer.


    I have a function which ist called "f_LCDPrint" and has got a
    pointer as input variable.


    void f_LCDPrint(char *str){


        char i = 0;


       


        while(str[i]) f_WriteData((char)str[i++]);


        return;   


    }


     


    If I called the function in main-routine as follow it works
    well:


    char chrfeld[] = "Hello World";


    LCDPrint(chrfeld);


     


    But if I called the function as follow it compiled without
    warnings but, the Compiler put the call of the function into
    rom_far memory.


    f_LCDPrint("Hello World");


     


    My Question is: How can I avoid, that creation of rom_far,
    Becaus the flash program will be need more time to flash and the
    program would npt work after flashed. What is this far memory?



  • >char chrfeld[] = "Hello World";
    area that would filled with the datas declared, that means that the
    ROM will be "fed" with a string containing "Hello World", a RAM
    area is reserved and immediately before main() is executed the
    content is copied from ROM to RAM, essentially wasting that RAM
    area.


     


    Thus I would have chosen to declare the constant as:


    const char chrfeld[] = "Hello World";


    and that might be all that's needed, otherwise I would have
    looked in the manuals for instructions specifying locations for
    constants.



  • Hello Icecap,


    thanks for your help.


    It is correct that char chrfeld[] = "Hello World"; is called
    from in the internal RAM area and const char chrfeld[] = "Hello
    World"; will be called from the internal ROM(rom far_section).


     


    But my problem ist the direct declaration in the call of the
    function. Like f_LCDPrint("Hello World");


    The Compiler will set this call into a rom_far section and so
    the flash program will need so many time to flash the R32C.


    What can I do, that the call of the function will not be
    inserted to the rom_far(internal ROM) section?


    Can I change some settings in the Compiler or are there some
    instructions to change far to near?


     


    Thanks for your help!



  • What you write is also the const char as Icecap wrote it, only
    that is implicitly defined by writing the char string directly in
    your argument.


    Of course you can cast it to near const, but it still needs to
    be flash. Strings must always be in flash. Where else should a
    const value be stored? Also the char chrfeld Icecap wrote has a
    string in far ROM The only difference is that the compiler copies
    the contents of far ROM to RAM automatically at application start.
    So it needs the memory twice.


    And why does a flash programming time concern you as it is
    needed only once when writing your software to the device? Pure
    programming time of 64KB in R32C should be less than 1 second.



  • Ok, I solve my problem. I define the wrong start adress for
    rom_far. If I type the right adress my program works and the flash
    programmer will be work faster.


     


    Thanks for your help.