ThrowTheSwitch/CMock — pull request #5 by JSchaenzle (2012-10-04 18:27:56+00:00)
Title: Added cast to CMOCK_MEM_INDEX_SIZE for 16bit compiler

I have been going through an exercise of setting up Ceedling for a PIC project which uses the Microchip C30 compiler. This is a 16 bit compiler. In my projec.yml I added the following defines:

- CMOCK_MEM_INDEX_TYPE=uint16_t
- CMOCK_MEM_PTR_AS_INT=uint16_t
- CMOCK_MEM_ALIGN=(1)
- CMOCK_MEM_SIZE=4096

When attempting to build the project I got the error output from the compiler that is shown below. The line of interest is this

**cmock.c:117:16: error: cast to pointer from integer of different size**

The cast that I added in this pull request fixes the issue but I am not 100% sure it is the right thing to do. Can someone who has a really good understanding of the inner-workings of CMock take a look at this and verify the change?

If you want to see the entire project I am working on let me know. I will be putting it on GitHub soon anyways.

_____________________________________________________________________________
Complete Output:

Compiling cmock.c...
Options have been disabled due to restricted license
Visit http://www.microchip.com/ to purchase a new key.
elf-cc1.exe: warnings being treated as errors
C:/Users/Jordan/Projects/Atomic/BlogPost/PIC_TDD_Example/vendor/ceedling/vendor/cmock/src/cmock.c: In function 'CMock_Guts_MemChain':
C:/Users/Jordan/Projects/Atomic/BlogPost/PIC_TDD_Example/vendor/ceedling/vendor/cmock/src/cmock.c:117:16: error: cast to pointer from integer of different size
C:/Users/Jordan/Projects/Atomic/BlogPost/PIC_TDD_Example/vendor/ceedling/vendor/cmock/src/cmock.c:123:6: error: cast to pointer from integer of different size
C:/Users/Jordan/Projects/Atomic/BlogPost/PIC_TDD_Example/vendor/ceedling/vendor/cmock/src/cmock.c: In function 'CMock_Guts_MemNext':
C:/Users/Jordan/Projects/Atomic/BlogPost/PIC_TDD_Example/vendor/ceedling/vendor/cmock/src/cmock.c:143:12: error: cast to pointer from integer of different size
ERROR: Shell command failed.
> Shell executed command:
'xc16-gcc.exe -mcpu=24HJ128GP202 -x c -c C:/Users/Jordan/Projects/Atomic/BlogPost/PIC_TDD_Example/vendor/ceedling/vendor/cmock/src/cmock.c -o"build/test/out/cmock.o" -D__PIC24HJ128GP202__ -DTEST -DUNI
TY_INT_WIDTH=16 -DCMOCK_MEM_INDEX_TYPE=uint16_t -DCMOCK_MEM_PTR_AS_INT=uint16_t -DCMOCK_MEM_ALIGN=(1) -DCMOCK_MEM_SIZE=4096 -I"test" -I"C:/Program Files (x86)/Microchip/mplabc30/v3.31/bin" -I"test/sup
port" -I"src" -I"src/device_specific" -I"C:/Microchip Solutions v2012-04-03/Microchip/Include" -I"C:/Users/Jordan/Projects/Atomic/BlogPost/PIC_TDD_Example/vendor/ceedling/vendor/unity/src" -I"C:/Users
/Jordan/Projects/Atomic/BlogPost/PIC_TDD_Example/vendor/ceedling/vendor/cmock/src" -I"build/test/mocks" -Wall -Werror -Os -mlarge-code -mlarge-arrays'
> And exited with status: [255].

rake aborted!