Thread: Old source code dereferencing non-pointer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218

    Old source code dereferencing non-pointer

    Hi all

    I have some really old code for a PIC16 microprocessor, compiler not 100% known but it might be ccs, that in a couple of parts does the following:
    Code:
    int16 p_16;
    int8 eeadr=73; //70..73
    int8 i;
    p_16=&variable;    // variable is of type int32
    for (i=1;i<=4;++i)
    {
       *p_16=read_eeprom (eeadr);
        p_16++;
        eeadr--;
    }
    I know this isn't legal C but bear in mind that the source code initially was case insensitive so...

    My question is, does anybody see any potential that this can cause issues with an ever growing stack etc. Or any other issues (apart from not correct C)? int16 is NOT typedefed/defined to a pointer type, it is used as a value type in other parts of the same source file.

    The microcontroller is reset every now and then, because of (what we hear) stability issues, and we are trying to find out what can cause that, and this snippet of code stood out.

    Anybody has any tips/leads/something/anything?

    Are there any known compilers where a p_ prefix to variables will cause the variable to actually be a pointer (thus the code is a non-issue)?
    Last edited by Shakti; 02-26-2015 at 01:25 AM.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dereferencing pointer to incomplete type
    By johnny_ in forum C Programming
    Replies: 4
    Last Post: 03-01-2010, 10:46 AM
  2. Replies: 4
    Last Post: 08-27-2007, 11:51 PM
  3. dereferencing void pointer
    By nkhambal in forum C Programming
    Replies: 4
    Last Post: 04-25-2005, 02:47 AM
  4. dereferencing a void pointer
    By cricket in forum C Programming
    Replies: 8
    Last Post: 09-12-2003, 04:09 PM
  5. Dereferencing Pointer
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 02-01-2002, 07:52 AM