Release Notes for MPLAB® C18 C Compiler
v3.03
7 April 2006

Table of Contents
  1. Important MPLINK and MPLAB IDE Compatibility Note
  2. What's New in This Release
  3. What's Been Fixed Since v3.00
  4. Devices Supported
  5. MPLAB C18 C Compiler Documentation
  6. Documentation Update
  7. Installation
  8. Using MPLAB C18 with the MPLAB IDE
  9. Known Problems
  10. Contributors
  11. Customer Support
  1. Important MPLINK and MPLAB IDE Compatibility Note

  2. Due to a change in COFF file format, MPLAB C18 v3.00 and later will not be compatible with versions of MPLINK prior to v4.00 or versions of the MPLAB IDE prior to v7.21.

    MPLAB C18 v3.00 and later will have backward compatibility to earlier versions at the source level only. Any existing object files or libraries compiled with earlier versions of the tools will not link using new versions of the tools. They will need to be recompiled from source.

    If the user attempts to use this release with object files or libraries compiled with earlier versions of MPLAB C18, MPLINK, and MPASM, the error message that will be received will be similar to:

    Error - Coff file format for 'C:\mcc18\lib/c018i.o' is out of date.
    

    If the user attempts to use an old version of MPLINK to link object files or libraries compiled with this release, the error message that will be received will be similar to:

    Error - Coff file format for 'C:\mcc18\lib/c018i.o' does not appear to be a valid COFF file.
    
  3. What's New in This Release

    • Numerous bug fixes. See section 3 below.

    • No new features.
  4. What's Been Fixed Since v3.00:

    1. Fixed between v3.02 and 3.03:

      (28214)
      For the 18F4550 family, the following list of volatile SFRs were not treated as volatile in the device support files:
        SPPCFG
        SPPCON
        SPPEPS
        UCON
        UADDR
        UCFG
        UEP0
        UEP1
        UEP2
        UEP3
        UEP4
        UEP5
        UEP6
        UEP7
        UEP8
        UEP9
        UEP10
        UEP11
        UEP12
        UEP13
        UEP14
        UEP15
      
      Support files for the following devices were corrected:
      18F2450, 18F2455, 18F2550, 18F4450, 18F4455, and 18F4550.

      (27893)
      Bits were missing in support files for devices 18F1330 and 18F1230 according to data sheet DS39758A.
      SEVTEN (ADCON0<7>) and INTSRC (OSCTUNE<7>) have been added.
      CVROE (CVRCON<6>) and FLTCON (FLTCONFIG) are unimplemented and were removed.
      Correct bit names for DTCON have been added.

      (27953)
      For 18F87J10, the config directive for the Processor Mode Selection (External Memory Bus Configuration) bits (MODE =) defined the bits in reverse order.
      The bits are now defined in the correct order.
      NOTE: The workaround recommended for this issue in the previous release, v3.02, is no longer valid.
      When using the #pragma config directive, please follow the instructions in the PIC18 Config Settings Help file for Processor Mode Selection:

      MMinstead of XM20for MCU mode - External bus disabled
      XM12instead of XM16for Extended MCU mode, 12-bit Address mode
      XM16instead of XM12for Extended MCU mode, 16-bit Address mode
      XM20instead of MMfor Extended MCU mode, 20-bit Address mode

      The MPLAB IDE settings were always correct. Only the #pragma config directive settings were incorrect.


      (28136)
      The 18F4680 family support files did not match data sheet DS39625B.

      Configuration Word changes for 18F2585/2680/4584/4680:
      ------------------------------------------------------
      OSC setting - ERC value has been removed. Use RC
      OSC setting - ERC1 value has been removed. Use RC
      FCMENB setting has been changed to FCMEN
      IESOB setting has been changed to IESO
      BOR setting has been changed to BOREN
      BORV setting value 20 has been changed to 3
      BORV setting value 27 has been changed to 2
      BORV setting value 42 has been changed to 1
      BORV setting value 45 has been changed to 0

      Additional Configuration Word changes for 18F2585/4585:
      --------------------------------------------------------
      CP3 setting has been removed
      WRT3 setting has been removed
      EBTR3 setting has been removed

      SFR changes for 18F2585/2680/4585/4680 .h files:
      ------------------------------------------------
      CANSTAT bit 1 has been renamed from ICODE0 to ICODE1
      CANSTAT bit 2 has been renamed from ICODE1 to ICODE2
      CANSTAT bit 3 has been renamed from ICODE2 to ICODE3

      T3ECCP1 (on T3CON) was incorrectly defined as bit 5 but has been corrected to bit 6.


      (26624)
      In the header file for 18F8680 the FIFOWMIF bit was missing from PIR3.

      (27988)
      RE3 bit of PORTE was missing in 18F2431 and 18F2331 devices header files and INC files. It has been added.

      (27157)
      Some SFRs and bits were missing from the 18F2480\2580\4480\4580 devices according to data sheet DS39637A.
      The following updates have been made to device support files:

      Configuration Word changes for 18F2480/2580/4480/4580:
      -----------------------------------------------------
      OSC setting - ERC value has been removed. Use RC
      OSC setting - ERC1 value has been removed. Use RC
      FCMENB setting has been changed to FCMEN
      IESOB setting has been changed to IESO
      BOR setting has been changed to BOREN
      BORV setting value 20 has been changed to 3
      BORV setting value 27 has been changed to 2
      BORV setting value 42 has been changed to 1
      BORV setting value 45 has been changed to 0

      Additional Configuration Word changes for 18F4480:
      --------------------------------------------------
      CP2 and CP3 settings have been removed
      WRT2 and WRT3 settings have been removed
      EBTR2 and EBTR3 settings have been removed

      SFR changes for 18F2480/2580/4480/4580 .h files:
      ------------------------------------------------
      T3ECCP1 (on T3CON) was incorrectly defined as bit 5 but has been corrected to bit 6
      EXIDEN (on RXF1SIDL)was incorrectly defined as bit 1 but has been corrected to bit 3
      EXIDE (on B1SIDL)was incorrectly defined as bit 1 but has been corrected to bit 3

      CANSTAT bit 1 has been renamed from ICODE0 to ICODE1
      CANSTAT bit 2 has been renamed from ICODE1 to ICODE2
      CANSTAT bit 3 has been renamed from ICODE2 to ICODE3

      (21933)
      Using the name of a structure variable instead of the structure tag in the return type of a function could generate a crash.


      (27927)
      The "pow" function generated a link time error if the default storage class was static.


      (27943)
      An array of struct as a member of of another struct would cause an invalid COFF file.



    2. Fixed between v3.01 and 3.02:

      (27624)
      Using any of a set of symbols reserved for use by the compiler caused the compiler to emit a "type mismatch in redeclaration" error. The following symbols are no longer reserved for use by the compiler:
        AEXP
        BEXP
        AARGB0
        AARGB1
        AARGB2
        AARGB3
        AARGB4
        AARGB5
        AARGB6
        AARGB7
        BARGB0
        BARGB1
        BARGB2
        BARGB3
        REMB0
        REMB1
        REMB2
        REMB3
        TEMP
        TEMPB0
        TEMPB1
        TEMPB2
        TEMPB3
        FPFLAGS
        FPFLAGSbits
      
      If you are using any of these names to refer to the math library's variables, these can now be accessed by prefixing the symbol name with two underscores (e.g., __FPFLAGS).

      (27800)
      Auto context saving saved a symbol twice if the symbol was in the "save=" clause and auto context saving determined it needed to save the symbol.


      (27884)
      The header files for the 18F87J10 family of devices were missing SSPCON bits. Per DS39663B, SSP1CON2 bits 1 through 5 and SSP2CON2 bits 1 through 5 (ADMSK1-ADMSK5) were added.


      (27895)
      Header files for 18F4450 and 18F2450 did not have support for EUSART. BAUDCON, SPBRGH, EECON1 and EECON2 registers have been added. Missing bit SENDB on TXSTA register was added.


    3. Fixed between v3.00 and 3.01:

      (24022)
      Compiler crashes on pointer arithmetic using pointer to incomplete tag (illegal code).


      (24411)
      Cannot use a comma-containing constant string as an argument to a macro.


      (24420)
      atob() function, called with a string containing a negative value, corrupts the software stack.


      (26834)
      (Extended-mode only) Struct assignment with pointer arithmetic has been fixed.


      (27682)
      TABLAT could be corrupted by function epilogue code.


      (27358 / 27515)
      The #pragma config directive causes unimplemented bits to become 0, but should be left a '1'.
      Unimplemented/reserve bits are now included in the mask and default settings when the bit must be maintained set.

      Following are the devices and configuration words that were corrected:
              18C442  CONFIG1H, CONFIG4L
              18C452  CONFIG1H, CONFIG4L
              18C658  CONFIG1H, CONFIG4L
              18C858  CONFIG1H, CONFIG4L
              18F242  CONFIG5L, CONFIG6L, CONFIG7L
              18F442  CONFIG5L, CONFIG6L, CONFIG7L
              18F6525 CONFIG3L, CONFIG5L, CONFIG6L, CONFIG7L
              18F6621 CONFIG3L
              18F8525 CONFIG5L, CONFIG6L, CONFIG7L
              18F2220 CONFIG5L, CONFIG6L, CONFIG7L
              18F4220 CONFIG5L, CONFIG6L, CONFIG7L
              18F2439 CONFIG5L, CONFIG6L, CONFIG7L
              18F4439 CONFIG5L, CONFIG6L, CONFIG7L
              18F2525 CONFIG5L, CONFIG6L, CONFIG7L
              18F4525 CONFIG5L, CONFIG6L, CONFIG7L
              18F6520 CONFIG2L, CONFIG2H, CONFIG3L, CONFIG3H, CONFIG5L,
                      CONFIG6L, CONFIG7L
              18F6620 CONFIG3L, CONFIG5L, CONFIG6L, CONFIG7L
              18F6720 CONFIG3L
              18F8520 CONFIG2L, CONFIG2H, CONFIG3H, CONFIG5L, CONFIG6L,
                      CONFIG7L
              18F8620 CONFIG5L, CONFIG6L, CONFIG7L
      
      18F2331 and 18F2431 had extra settings removed that are unimplemented on these devices as follows:
      CONFIG5L - Removed settings for CP2 and CP3.
      CONFIG6L - Removed settings for WRT2 and WRT3.
      CONFIG7L - Removed settings for EBTR2 and EBTR3.

      In addition, 18F2525, 18F2620, 18F4525 and 18F4620 had their value names modified in CONFIG2L for the BORV setting to be 3 (for Minimum setting), 2, 1, and 0 (for Maximum setting).


      (27518)
      SWDTEN bit should be 0th bit, but the bit location is 7 on 18F4321 family devices. For all devices, changed SWDTEN on SFR WDTCON from bit 7 to bit 0.


      (27519)
      18F4321 family device support changes needed to match the data sheet DS39689A.

      All devices:
      -----------
      Added SFR ECCP1DEL
      Added SFR HLVDCON
      Added missing bits 4 and 5 (TXCKP and RXDTP) to BAUDCON
      Added missing bits 6 and 7 (P1M0 and P1M1) to CCP1CON
      Added missing bit 2 (HLVDIP) to IPR2
      Added missing bit 2 (HLVDIE) to PIE2
      Added missing bit 2 (HLVDIF) to PIR2
      Added missing bits 0-4 (SP0, SP1, SP2, SP3, SP4) to STKPTR
      Added missing bits 1-5 (ADMSK1, ADMSK2, ADMSK3, ADMSK4, ADMSK5) in SSPCON2
      Changed CONFIG1H FSCM to FCMEN
      Changed CONFIG2L BORV settings to 3 (Minimum setting), 2, 1, and 0 (Maximum setting)
      Corrected CONFIG3H default settings
      Changed CONFIG3H LPT1OSC setting names from LOW and HIGH to ON and OFF to be consistent with other devices
      Changed CONFIG3H PBAD to PBADEN
      Corrected CONFIG4L default settings
      Updated Configuration descriptions to match data sheet

      18F2221/18F2321
      ---------------
      Removed ICPORT from CONFIG4L - unimplemented on these devices.


      (27612)
      18F4520 family device support changes needed to match the data sheet DS39631A.

      All devices
      -----------
      Updated Configuration descriptions to match data sheet
      Change CONFIG2L BORV settings to 3 (Minimum setting), 2, 1, and 0 (Maximum setting)

      18F4520
      -------
      Removed SFR EEADRH - unimplemented on this device

      18F4420
      -------
      Removed SFR DEBUG - unimplemented on this device
      Removed - SFR TRISE bits TRISE7, TRISE6, TRISE5, TRISE4 - not in data sheet
      Removed - SFR PORTB bits DAD5, DAD6, DAD7 - not in data sheet
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings for unimplemented but maintained set bits

      18F2520
      -------
      Added missing SFRs PWM1CON and ECCP1AS
      Removed SFR EEADRH
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST

      18F2420
      -------
      Removed SFR DEBUG - unimplemented on this device
      Added missing SFRs PWM1CON and ECCP1AS
      Removed - SFR PORTB bits DAD5, DAD6, DAD7 - not in data sheet
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings for unimplemented but maintained set bits


      (27614)
      18F4550 family device support changes needed to match the data sheet DS39632B.

      All devices
      -----------
      Corrected bit positions of TUN3 and TUN4 in OSCTUNE
      UFRMH and UFRML - Add bit names to these register
      Updated Configuration descriptions to match the data sheet
      In CONFIG2L, changed BORV settings to 3 (Minimum setting), 2, 1, and 0 (Maximum setting)

      18F4550
      -------
      Added bits to CCP1DEL and CCP1AS.
      Corrected default values in CONFIG1L, CONFIG2L and CONFIG3H

      18F4455
      -------
      Added bits to CCP1DEL and CCP1AS
      Corrected default values in CONFIG1L, CONFIG2L and CONFIG3H
      Removed CP3 from CONFIG5L, WRT3 from CONFIG6L and EBTR3 from
      CONFIG7L - they are not available in this device

      18F2550
      -------
      Added ECCP1AS and ECCP1DEL and their bits
      Corrected default values in CONFIG1L, CONFIG2L and CONFIG3H
      Removed ICPRT from CONFIG4L - it is not available in this device

      18F2455
      -------
      Added ECCP1AS and ECCP1DEL and their bits
      Corrected default values in CONFIG1L, CONFIG2L and CONFIG3H
      Removed ICPRT from CONFIG4L, CP3 from CONFIG5L, WRT3 from CONFIG6L and EBTR3 from CONFIG7L - they are not available in this device


      (27615)
      18F8410 family device support changes needed to match the data sheet DS39635A.

      18F6310, 18F6410, 18F8310 and 18F8410
      -------------------------------------
      Removed EEIP from SFR IPR2 - unimplemented in data sheet
      Removed EEIE from SFR PIE2 - unimplemented in data sheet
      Removed EEIF from SFR PIR2 - unimplemented in data sheet
      Removed TUN5 from SFR OSCTUNE - unimplemented in data sheet

      Updated Configuration descriptions to match data sheet
      Changed CONFIG2L BORV settings to 3 (Minimum setting), 2, 1, and 0 (Maximum setting)
      CONFIG3H - corrected default settings for unimplemented but maintain set bits

      18F6310 and 18F6410
      -------------------
      CONFIG3L is unimplemented but to keep the default values set it has been added. No settings are available so it can not be changed
      Changed CONFIG3H PORTTBE setting to PORTE
      CONFIG7L is unimplemented for these devices but to keep the default values set it will remain but the EBTR setting is removed


      (27618)
      18F87J10 family device support changes needed to match the data sheet DS39663A.

      All devices
      -----------
      STKPTR - added bits SP4, SP3, SP2, SP1, SP0
      INTCON2 - added bit INT3IP
      ADCON0 - added bit ADCAL
      CCP1CON - added bits P1M1, P1M0
      CCP2CON - added bits P2M1, P2M0
      CCP3CON - added bits P3M1, P3M0
      ECCP1AS - added bits PSS1AC0, PSS1AC1, ECCP1AS0, ECCP1AS1, ECCP1AS2, ECCP1ASE
      EECON2 - added SFR
      EECON1 - added SFR and bits FREE, WRERR, WREN, WR
      OSCTUNE - corrected size of PLLEN
      BAUDCON1 - added bit RCIDL
      BAUDCON2 - added bit RCIDL
      ECCP1DEL - added bits P1DC0, P1DC1, P1DC2, P1DC3, P1DC4, P1DC5, P1DC6, P1RSEN
      ECCP3AS - added bits PSS3AC0, PSS3AC1, ECCP3AS0, ECCP3AS1, ECCP3AS2, ECCP3ASE
      ECCP3DEL - added bits P3DC0, P3DC1, P3DC2, P3DC3, P3DC4, P3DC5, P3DC6, P3RSEN
      ECCP2AS - added bits PSS2AC0, PSS2AC1, ECCP2AS0, ECCP2AS1, ECCP2AS2, ECCP2ASE
      ECCP3DEL - added bits P2DC0, P2DC1, P2DC2, P2DC3, P2DC4, P2DC5, P2DC6, P2RSEN
      CONFIG1H - correct default settings
      Updated configuration descriptions to match data sheet

      18F87J10/86J15/86J10/85J15/85J10
      --------------------------------
      ECCP1AS - added bits PSS1BD0, PSS1BD1
      PORTG - added bits RDPU, REPU, RJPU

      18F67J10/66J15/66J10/65J15/65J10
      --------------------------------
      Removed MEMCON - unimplemented on these devices
      PORTG - added bits RDPU, REPU
      Added CONFIG3L with no settings to maintain default values
      CONFIG3H - correct default settings

      (27621)
      18F4610 family device support changes needed to match the data sheet DS39636A.

      All devices
      -----------
      Updated Configuration descriptions to match data sheet
      Change CONFIG2L BORV settings to 3 (Minimum setting), 2, 1, and 0 (Maximum setting)

      18F4610
      -------
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST

      18F4515
      -------
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings

      18F4510
      -------
      CONFIG5H, CONFIG6H - corrected default settings

      18F4410
      -------
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST
      CONFIG5L, CONFIG5H, CONFIG6L, CONFIG6H, CONFIG7L - corrected default settings

      18F2610
      -------
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST

      18F2515
      -------
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings

      18F2510
      -------
      CONFIG5H, CONFIG6H - corrected default settings

      18F2410
      -------
      CONFIG3H - added missing setting for LPT1OSC
      CONFIG4L - changed setting name ENHCPU to XINST
      CONFIG5L, CONFIG5H, CONFIG6L, CONFIG6H, CONFIG7L - corrected default settings

      (27622)
      18F44J10 family device support changes needed to match the data sheet DS39682A.

      All devices
      -----------
      Updated configuration descriptions

      18F45J10/18F44J10
      -----------------
      Added bit 7 - P1M1 and bit 6 - P1M0 to CCP1CON

      (27623)
      18F8722 family device support changes needed to match the data sheet DS39646B.

      All devices
      -----------
      Updated Configuration descriptions to match data sheet
      Change CONFIG2L BORV settings to 3 (Minimum setting), 2, 1, and 0 (Maximum setting)

      18F6527
      -------
      CONFIG3H - changed setting name PORTB to PORTE
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings

      18F6622
      -------
      CONFIG3H - changed setting name PORTB to PORTE
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings

      18F6627
      -------
      CONFIG3H - changed setting name PORTBE to PORTE
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings

      18F6722
      -------
      CONFIG3H - changed setting name PORTBE to PORTE

      18F8527
      -------
      CONFIG3H - changed setting name PORTB to PORTBE
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings

      18F8622
      -------
      CONFIG3H - changed setting name PORTB to PORTBE
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings

      18F8627
      -------
      CONFIG5L, CONFIG6L, CONFIG7L - corrected default settings

      (27639)
      18F8490 family device support changes needed to match the data sheet DS39629B.

      18F6390, 18F6490, 18F8390 and 18F8490
      -------------------------------------
      Removed EEIP from SFR IPR2 - unimplemented in data sheet
      Removed EEIE from SFR PIE2 - unimplemented in data sheet
      Removed EEIF from SFR PIR2 - unimplemented in data sheet
      Removed TUN5 from SFR OSCTUNE - unimplemented in data sheet
      Updated Configuration descriptions to match data sheet
      Changed CONFIG2L BORV settings to 3 (Minimum setting), 2, 1, and 0 (Maximum setting)
      CONFIG3H - corrected default settings
      Removed CONFIG7L it is not implemented in these devices

      (27736)
      In previous releases, the MPLAB C18 installer could corrupt the PATH environment variable, causing variables within the PATH variable to not be expanded. Since the system variable SystemRoot is often part of several important PATH entries, many commands could not be found after this.

      (27737)
      Auto context saving was not saving locations when a TBLRD instruction was generated. For example, a CALL instruction followed by a MOVF where the 'd' bit was not set would cause the location to not be saved.

  5. Devices Supported


    The MPLAB C18 C compiler (MCC18.EXE) is an ANSI C compiler for the PIC18 family of PICmicro controllers. It currently supports the following PICmicro MCUs:
    18C242       18C252       18C442       18C452
    18C601       18C658       18C801       18C858
    
    18F1220      18F1230      18F1231      18F1320
    18F1330      18F1331      18F2220      18F2221
    18F2320      18F2321      18F2331      18F2410
    18F242       18F2420      18F2423      18F2431
    18F2439      18F2450      18F2455      18F248
    18F2480      18F24J10     18F2510      18F2515
    18F252       18F2520      18F2523      18F2525
    18F2539      18F2550      18F258       18F2580
    18F2585      18F25J10     18F25K20     18F2610
    18F2620      18F2680      18F2681      18F2682*
    18F2685      18F4220      18F4221      18F4320
    18F4321      18F4331      18F4410      18F442
    18F4420      18F4423      18F4431      18F4439
    18F4450      18F4455      18F448       18F4480
    18F44J10     18F4510      18F4515      18F452
    18F4520      18F4523      18F4525      18F4539
    18F4550      18F458       18F4580      18F4585
    18F45J10     18F45K20     18F4610      18F4620
    18F4680      18F4681      18F4682*     18F4685
    18F6310      18F6390      18F63J11*    18F63J90
    18F6410      18F6490      18F64J11*    18F64J15
    18F64J90     18F6520      18F6525      18F6527
    18F6585      18F65J10     18F65J11*    18F65J15
    18F65J90     18F6620      18F6621      18F6622
    18F6627      18F6680      18F66J10     18F66J15
    18F66J60     18F66J65     18F6720      18F6722
    18F67J10     18F67J60     18F8310      18F8390
    18F83J11*    18F83J90     18F8410      18F8490
    18F84J11*    18F84J15     18F84J90     18F8520
    18F8525      18F8527      18F8585      18F85J10
    18F85J11*    18F85J15     18F85J90     18F8620
    18F8621      18F8622      18F8627      18F8680
    18F86J10     18F86J15     18F86J60     18F86J65
    18F8720      18F8722      18F87J10     18F87J60
    18F96J60     18F96J65     18F97J60
    

    * New part support since last release
    Note: The devices 18F2423, 18F2523, 18F4423, and 18F4523 were formerly known as 18LF2423, 18LF2523, 18LF4423, 18LF4523.

    Of the above parts only the following parts will support the extended mode instruction set:
    18F1230      18F1231      18F1330      18F1331
    18F2221      18F2321      18F2410      18F2420
    18F2423      18F2450      18F2455      18F2480
    18F24J10     18F2510      18F2515      18F2520
    18F2523      18F2525      18F2550      18F2580
    18F2585      18F25J10     18F25K20     18F2610
    18F2620      18F2680      18F2682      18F2685
    18F4221      18F4321      18F4410      18F4420
    18F4423      18F4450      18F4455      18F4480
    18F44J10     18F4510      18F4515      18F4520
    18F4523      18F4525      18F4550      18F4580
    18F4585      18F45J10     18F45K20     18F4610
    18F4620      18F4680      18F4682      18F4685
    18F6310      18F6390      18F63J11     18F63J90
    18F6410      18F6490      18F64J11     18F64J90
    18F6527      18F65J10     18F65J11     18F65J15
    18F65J90     18F6622      18F6627      18F66J10
    18F66J15     18F66J60     18F66J65     18F6722
    18F67J10     18F67J60     18F8310      18F8390
    18F83J11     18F83J90     18F8410      18F8490
    18F84J11     18F84J90     18F8527      18F85J10
    18F85J11     18F85J15     18F85J90     18F8622
    18F8627      18F86J10     18F86J15     18F86J60
    18F86J65     18F8722      18F87J10     18F87J60
    18F96J60     18F96J65     18F97J60
    

    THE PARTS CORRESPONDING TO THESE OPTIONS MAY NOT ALL BE COMMERCIALLY AVAILABLE.

  6. MPLAB C18 C Compiler Documentation

    The following document revisions are associated with this release:

    • MPLAB C18 C Compiler Getting Started (DS51295 revision F)
    • MPLAB C18 C Compiler User's Guide (DS51288 revision J)
    • MPLAB C18 C Compiler Libraries (DS51297 revision F)

    The current documentation is available from our web site: http://www.microchip.com/c18

    The following Help files are associated with this release:

    • PIC18 Configuration Settings Help (Updated March 31, 2006)
    • COFF File Format Help (Updated March 31, 2006)

    If the installation includes documentation, the files listed above are placed in the <install_dir>\doc directory.

  7. Documentation Update

    The information in the COFF File Format Help file (Updated March 31, 2006) supercedes the information found in Appendix A, COFF File Format, Table A-2 of the document:
    MPLAB C18 C Compiler User's Guide (DS51288 revision J)

  8. Installation

    MPLAB C18 requires the use of MPLINK™, Microchip's object linker; MPLAB C18 v3.00 or later will require MPLINK v4.00 or later. The latest version of MPLINK is included with the installation.

    To verify correct installation of MPLAB C18, execute the batch file <install_dir>\example\an696\buildit.bat. If the compiler system has been installed correctly, the file 18motor.out will be created.

    When installing MPLAB C18, the setup program offers the user the ability to change several environment settings. The following options are provided:

    Environment Variables:

    • Add MPLAB C18 to PATH environment variable
      The directory of the compiler executables is added to the beginning of the current PATH environment variable.
    • Add MPASM to PATH environment variable
      The directory of the MPASM executable is added to the beginning of the current PATH environment variable.
    • Add header file path to MCC_INCLUDE environment variable
      The location of the header (.h) files is added to the beginning of the user's MCC_INCLUDE environment variable. MPLAB C18 uses this setting to search for header files.
    • Modify PATH and MCC_INCLUDE variables for all users
      The options listed above are applied to the machine environment variables instead of the user environment variables, so that they affect all users and not just the current user.
      This option only appears if the user running the installer has administrative rights.

    MPLAB IDE Configuration:
    The options below only appear if the user has a version of MPLAB IDE installed.

    • Update MPLAB IDE to use this MPLAB C18
      Configuration settings used by the MPLAB IDE to find MPLAB C18 will be updated to indicate the location of this release.
    • Update MPLAB IDE to use this MPLINK, MPLIB, and MPASM
      Settings used by MPLAB IDE to find the MPLINK Linker, MPLIB Librarian, and MPASM Assembler will be updated to point to those in this release.
    • Update MPLAB IDE Help with MPLAB C18 documentation
      Documentation installed with MPLAB C18 will be made available from the Help menu of the MPLAB IDE.
      This option only appears if documentation is being installed.
    • Perform MPLAB IDE updates for all users
      The changes to the MPLAB IDE configuration are applied to the machine registry instead of that of the current user, so that they affect all users and not just the current user.
      This option only appears if the user running the installer has administrative rights.

    If MPLAB C18 is uninstalled, these changes to the IDE configuration will not be rolled back.

  9. Using MPLAB C18 with the MPLAB IDE

    See the document "MPLAB C18 C Compiler Getting Started Guide" for a step-by-step tutorial on using MPLAB C18 with the MPLAB IDE.

    The current documentation is available from our web site, http://www.microchip.com/c18

    NOTE: MPLAB C18 v3.00 and later will not be compatible with versions of the MPLAB IDE prior to v7.21.

  10. Known Problems

    The following are some of the known issues with MPLAB C18 v3.03. The first list presented, SSR SUMMARY, is a brief summary of each SSR, System Service Request, for ease of reference. For more details on an SSR, see that SSR in the list SSR DETAILS which follows.

    SSR SUMMARY

    General


    (28184)
    Values in an array at offsets greater than 128 are accessed incorrectly.
    (27011)
    No error message generated for run time assignment to a const struct.
    (27683)
    #pragma sectiontype does not throw an error on inappropriate arguments and does not create the named section.
    (27748)
    Directly using the result of invoking a function with a return value larger than 32 bits retrieves the return value in an interrupt unsafe manner.
    (23715)
    Enumeration value 127+1 extended to 0xFF80 but 127+2 is 0x0081.
    (23897)
    integer *= float-constant casts constant to integer before multiplication.
    (24130)
    A conflicting redefinition of type does not cause error or warning.
    (24481)
    Due to a COFF limitation, a greater than 16-bit relocation offset is calculated incorrectly at link-time.
    (25512)
    Mismatch in config values for BORV across many device families.
    (20189)
    (non-extended mode only) Passing a static parameter to a function pointer in a structure should generate an error message, but instead generates an internal compiler error.
    (20975)
    With integer promotions enabled, if the left operand of the >>= operator is negative, the result stored in the operand is incorrect.
    (21192)
    (non-extended mode only) The result of the %= operator where the left operand is a 24-bit or 32-bit rom variable is incorrect.
    (21261)
    (non-extended mode only) Calling a function pointer which has been converted from an object pointer generates an internal compiler error.
    (21693)
    Redefinitions of structure tags in nested scopes are not observed properly by MPLAB C18.
    (21905)
    Invocations of functions with return values larger than 32 bits retrieve the return value in an interrupt unsafe manner.
    (18405)
    Two global declarations with the same name may cause problems for the banking optimizer if the declarations are located in different banks.
    (22612)
    Combining a typedef name with a 'rom' type qualifier in a declaration assigns the incorrect type if 'rom' follows the typedef name.
    (22771)
    A legal redeclaration of an array changes the size of the array.
    (21634 / 23024)
    The assignment of the address of an object in constant program memory to a pointer to non-constant data memory does not generate a diagnostic.
    (23183)
    When the conditional (?:) operator is used with operands which are greater than 32 bits in size, an "irreducible tree" internal error may be generated.
    (21349 / 23238)
    Referencing a variable declared 'extern' with an initializer causes an internal failure.
    (18487)
    With the compound assignment operators, the usual type conversions which are to be performed on the operands are not done correctly when the left operand is 8 bits in size.
    (20359)
    There is a bug in the implementation of the scoping of typedef names.
    (22091)
    String literals are placed in program memory and so must be assigned to variables of type 'rom char *'. However, assigning one to a pointer to data memory does not generate a diagnostic.
    (22147)
    Octal constants which contain an '8' or '9' do not generate a diagnostic. Instead, the code compiles quietly, and the value used for the constant is indeterminate.
    (22768)
    The redeclaration of a structure tag should generate an error, but does not.
    (22784)
    A local variable declared 'rom' and 'extern' is disallowed when it should be permitted.
    (21514 / 22953)
    (non-extended mode only) Using static parameters with a function which has a variable number of arguments is not supported, but does not generate a compile time error.
    (26056)
    Unable to reduce tree for: if (local char * > parameter const rom far char * + constant)
    (27426)
    A struct causes the compiler to crash if it has a prototype but no definition.
    (27455)
    The volatile qualifier is not applied to struct members.
    (22483)
    MPLIB is unable to work with MPLAB C18 files compiled in the static overlay model.

    Inline Assembly


    (21443)
    Compiler crashes on invalid inline assembly code.
    (22557)
    In some cases, using a valid cast expression in inline assembly can cause a crash.
    (22170 / 22632)
    Incorrect use of automatic local variables in inline assembly code does not generate a warning or error.
    (22559)
    Enumeration constants in expressions which are operands of inline assembly instructions can cause an internal error to be generated.

    Preprocessor


    (21817)
    Preprocessor merging operator should take precedence over the stringization operator
    (23817)
    The preprocessor performs macro replacement within the text of a #error directive.
    (23827)
    Crash (after error message) for #elif with no preceding #if
    (23717 / 23844)
    Comments in a macro call may cause incorrect substitution or a syntax error.
    (24038)
    No error when #if does not have corresponding #endif and condition is true
    (25409)
    Preprocessor evaluates expressions in discarded lines of an #ifdef expression.
    (22522)
    The preprocessor may go into an infinite loop when expanding mutually recursive macros.
    (21252 / 25868)
    A macro invocation spanning more than one logical source file line may throw off line number information or cause the preprocessor to not output a line number, causing debugging difficulty in the MPLAB IDE.
    (26031)
    The preprocessor performs macro replacement inside a #pragma directive.
    (26397)
    A constant string ending with \\" causes any following text on the line to be treated as part of the string.
    (26385)
    The preprocessor does not throw an error on finding "#elsif"
    (25733)
    Using absolute path in "#include" directive causes compiler to put invalid file path in COFF file and error messages
    (27540)
    A malformed expression in a #if preprocessor directive on the last line of a file with no terminating end of line character may cause the preprocessor to crash.
    (27541)
    #undef on the last line of a source file with no terminating end of line may cause the preprocessor to crash.
    (28101)
    Circular or recursive macro defnitions can cause the preprocessor to take up all available CPU cycles and hang for a long time before giving an error.

    Libraries

    Note: From the release of MPLAB C18 v2.42 onward, no support has been or will be added to the peripheral libraries.

    (18624)
    The library routine 'atof' generates a result less precise than simply assigning a constant.
    (23497)
    Timer5, SPI, and I2C peripherals not implemented for 18F2331, 18F2431, 18F4331, and 18F4431; nor is the enhanced facility (function baudUSART) implemented for these devices.
    (26882)
    Library c018iz.o does not zero bank 15 at startup.

    Header Files


    None.

    User Error Screening


    (26595)
    Utilizing an enumerated type for a bitfield does not issue an error diagnostic.

    SSR DETAILS

    General


    (28184)
    Values in an array at offsets greater than 128 are accessed incorrectly.
    For example, for the code:
      #include <p18cxxx.h>
    
      typedef struct{
        unsigned char Name[130];
        unsigned char Length;
      }_Image;
    
      _Image EImage;
      _Image *pImage = &EImage;
    
      void main(void)
      {
        unsigned short Len;
        EImage.Length = 55;
        Len = pImage->Length;  // Wrong value of Len
      }
    
    The compiler will not use the correct offset to find the Length member of EImage.

    (27011)
    No error message generated for run time assignment to a const struct.
    For example, the code:
      typedef struct 
      { 
              int b; 
      } typeB; 
      
      const typeB objB; 
      
      void fB_type( ) 
      { 
              objB.b = 1;
      }
    
    does not generate an error.

    (27683)
    #pragma sectiontype does not throw an error on inappropriate arguments and does not create the named section.
    For example, the code:
      #pragma romdata whatever =
      const rom unsigned char = 0x71;
      #pragma romdata
    
    does not generate an error and does not create a section named whatever.

    (27748)
    Directly using the result of invoking a function with a return value larger than 32 bits retrieves the return value in an interrupt unsafe manner.
    The stack space for the return value may be deallocated before the return value is retrieved from the stack, causing potential return value corruption if an interrupt occurs after deallocation but before or during retrieval.
    For example, the code generated from the following C source exhibits the problem:
      struct A {long a, b;} X;
      extern struct A foo (void);
      long c;
      void main (void)
      {
        c = foo().b;
      }
    
    (23715)
    Enumeration value 127+1 extended to 0xFF80 but 127+2 is 0x0081.
    An enumeration constant that should have the value 128 instead has the value -128.
    For example:
      enum {
       R=127, // value = 127
       G,     // value = -128 *** incorrect ***
       B      // value = 129
      };
    
    Workaround: If an enumeration constant with a value of 128 is required, it should be explicitly given that value. For example,
      enum {
       R=127, // value = 127
       G=128, // value = 128
       B      // value = 129
      };
    
    (23897)
    integer *= float-constant casts constant to integer before multiplication.
    For example:
      volatile unsigned char uc_test;
      uc_test = 80;
      uc_test *= 0.7; /* Expected: 56, Actual: 0*/
    
    A workaround to this is to write the last statement as:
      uc_test = uc_test * 0.7;
    
    (24130)
    Conflicting redefinition of type does not cause error or warning.
    For example:
      typedef unsigned short long foo;
      typedef unsigned char foo;
      typedef unsigned short foo;
      typedef unsigned int foo;
      typedef unsigned long foo;
      typedef double foo;
      typedef long double foo;
      typedef struct
      {
        ...
      } foo;
      typedef union foo
      {
        ...
      } foo;
    
    It should cause the compiler to emit errors such as:
      test.c:3: error: conflicting types for `foo'
      test.c:2: error: previous declaration of `foo'
    
    (24481)
    Due to a COFF limitation, a greater than 16-bit relocation offset is calculated incorrectly at link-time.
    Microchip's Common Object File Format (COFF) contains a limitation in the relocation entry, which is the structure that implements the dynamics of relocation. In Microchip's COFF, the offset to add to the base address of the symbol is stored in the relocation entry. This differs from the System V relocation data in which the offset is stored in the location being relocated to. This difference is necessary because Microchip relocations are not restricted to just filling in an address + offset value into the data stream, but also to do simple code modifications. The limitation comes from the fact that this offset is defined as a short, which dictates that offsets may be no larger than 16-bit.
    The following example shows the side effect of this limitation:
      #pragma romdata constscn=0x2000
      rom const unsigned char var;
      #pragma romdata
    
      rom const unsigned char *varptr = &var + 0x8000;
    
    The above code gives the following relocation entries:
     Relocation: r_vaddr=0x00000000, r_symndx=2, r_offset=-32768, r_type=4
     Relocation: r_vaddr=0x00000001, r_symndx=2, r_offset=-32768, r_type=3
     Relocation: r_vaddr=0x00000002, r_symndx=2, r_offset=-32768, r_type=21
    
    Note that the r_offset field reflects an offset of -32k instead of +32k.

    A workaround is to use code for which the compiler will evaluate the offset at run-time.
    For example:
      void foo( void )
      {
        varptr = &var;
        varptr += 0x8000;
      }
    
    (25512)
    Mismatch in config values for BORV across many device families.
    For example, on the data sheet for the PIC18F8410 family, the BORV values are 2.1, 2.8, 4.3, 4.6
    But the equivalent values in the MPLAB C18 compiler are 25, 27, 42, 45.

    (20189) (non-extended mode only)
    Passing a static parameter to a function pointer in a structure should generate an error message, but instead generates an internal compiler error.
    For example:
      struct { void (*f) (static int x); } S;
      void main (void) { S.f (1); }
    
    (20975)
    With integer promotions enabled, if the left operand of the >>= operator is negative, the result stored in the operand is incorrect.
    For example, 'x' should be end up with -1, but instead ends up with 1:
      signed char x;
      x = 0x80;
      x >>= 7; /* 'x' should be -1, but is 1 instead */
    
    The integer promotions are not performed on 'x'.

    (21192) (non-extended mode only)
    The result of the %= operator where the left operand is a 24-bit or 32-bit rom variable is incorrect. For example:
      rom short long x;
      void main (void)
      {
        short long y;
        x = 1025;
        y = x %= 2; /* 'x' correctly receives 1, but 'y' does not */
        ...
    
    (21261) (non-extended mode only)
    Calling a function pointer which has been converted from an object pointer generates an internal compiler error. For example:
      unsigned long x[4];
      void main (void) { ((void (*)(void))x)( ); }
    
    (21693)
    Redefinitions of structure tags in nested scopes are not observed properly by MPLAB C18. For example:
      struct s { int x; } S;
      void main (void)
      {
        struct s; /* this introduces a new type, hiding the previous */
        struct s *Sp = &S; /* this is an incompatible assignment */
        Sp->x++;  /* invalid access of an incomplete type */
        ...
    
    The inner declaration of 'struct s' introduces a new (incomplete) type, which is different than the first 'struct s'. However, the above program compiles quietly. The structure tag is not redefined.

    (21905)
    Invocations of functions with return values larger than 32 bits retrieve the return value in an interrupt unsafe manner. The stack space for the return value is deallocated before the return value is retrieved from the stack, causing potential return value corruption if an interrupt occurs after deallocation but before or during retrieval.

    (18405)
    Two global declarations with the same name may cause problems for the banking optimizer if the declarations are located in different banks. For example:
      #pragma udata U1
      int i;
      #pragma udata U2
      int i;
    
    If U1 and U2 are allocated into different banks, references to 'i' may not be banked correctly after optimization. The solution is to use only one declaration of each global name.

    (22612)
    Combining a typedef name with a 'rom' type qualifier in a declaration assigns the incorrect type if 'rom' follows the typedef name. For example:
      typedef int *T;
      rom T p1;
      T rom p2;
    
    Both 'p1' and 'p2' should have type 'rom pointer to ram int'. Instead, only 'p1' has the correct type. 'p2' is given the type 'ram pointer to rom int'.

    (22771)
    A legal redeclaration of an array changes the size of the array.
    For example, following the declarations:
      char a[5];
      extern char a[];
    
    The size of 'a' is 1, not 5 as it should be.

    (21634 / 23024)
    The assignment of the address of an object in constant program memory to a pointer to non-constant data memory does not generate a diagnostic. For example:
      const rom char x;
      char *p;
      void main (void) { p = &x; ... }
    
    A diagnostic should be generated. The effect of referencing through 'p' following the assignment is indeterminate.

    (23183)
    When the conditional (?:) operator is used with operands which are greater than 32 bits in size, an "irreducible tree" internal error may be generated. For example:
      struct s
      {
        unsigned long x;
        char y;
      } S, T;
    
      void main (void)
      {
        char b;
        unsigned long z;
    
        ...
        z = (b ? S : T).x;
        ...
    
    generates such an error. The workaround is to use an 'if' statement instead of the conditional operator.

    (21349 / 23238)
    Referencing a variable declared 'extern' with an initializer causes an internal failure. For example:
      extern int x = 5;
      void main (void) { x++; }
    
    generates an internal error. The workaround is to remove the 'extern' storage class specification or remove the initializer.

    (18487)
    With the compound assignment operators, the usual type conversions which are to be performed on the operands are not done correctly when the left operand is 8 bits in size. This can cause problems in these instances:

    -- With integer promotions enabled, the compound assignment division operator may return incorrect results on 8-bit operands when the left operand is signed and the right is unsigned. The workaround is to replace:
      signed char x;
      unsigned char y;
      ...
      x /= y;
    
    with:
      signed char x;
      unsigned char y;
      ...
      x = x / y;
    
    -- The compound assignment remainder operator may return incorrect results when the right operand is greater than 8 bits in size. The workaround is to replace
      unsigned char x;
      unsigned short y;
      ...
      x %= y;
    
    with:
      unsigned char x;
      unsigned short y;
      ...
      x = x % y;
    
    (20359)
    There is a bug in the implementation of the scoping of typedef names.
    The following example generates a syntax error:
      void main (void)
      {
        typedef int X;
        {
          struct Y { int X; };
          (X)3; /* this should refer to the typedef name,
                 * not the structure member */
        }
      }
    
    The textually intervening declaration of 'X' as a structure member causes the typedef declaration of 'X' to be lost.

    (22091)
    String literals are placed in program memory and so must be assigned to variables of type 'rom char *'. However, assigning one to a pointer to data memory does not generate a diagnostic. For example:
      char *s = "hello world";
    
    Any references through 's' will result in indeterminate behavior.

    (22147)
    Octal constants which contain an '8' or '9' do not generate a diagnostic. Instead, the code compiles quietly, and the value used for the constant is indeterminate.

    (22768)
    The redeclaration of a structure tag should generate an error, but does not. For example:
      struct foo { int a; };
      struct foo { char b; };
    
      struct foo F;
    
    compiles quietly without error. The variable 'F' takes on the type of the second declaration.

    (22784)
    A local variable declared 'rom' and 'extern' is disallowed when it should be permitted. The error messages generated incorrectly refer to the declaration as 'auto'. For example:
      void main (void) { extern rom int x; }
    
      Error: local 'x' in program memory can not be 'auto'
    

    (21514 / 22953) (non-extended mode only)
    Using static parameters with a function which has a variable number of arguments is not supported, but does not generate a compile time error. Instead, a link time error is emitted which may not be comprehensible:
      Error - could not find definition of symbol '_foo:101' ...
    
    Such would be the error message if the function in question is called 'foo'.

    (26056)
    Unable to reduce tree for if (local char * > parameter const rom far char * + constant)

    For both extended and non-extended modes, the following function:
      void foo(const rom far char * FullPath, char *Path, char *FileName)
      {
        char *NameStart;
        char *s;
      
        if ((NameStart > FullPath + 1) && (*(Path - 1) == '\\'))
          return;
      }
    
    results in:
      Fatal [100] - internal - unable to reduce tree
    
    The problem is caused by comparing the address of a pointer located on the stack (i.e. ram) with one located in rom. This is not a valid comparison and should result in an error.

    (27426)
    A struct causes the compiler to crash with a segmentation fault if the struct has a prototype but no definition.
    For example:
      struct complex new_complex(double r, double i);
      
      void main (void)
      {
          new_complex(10.55, 12.44);
          return;
      }
    
    (27455)
    The volatile qualifier is not applied to struct members.
    For the following source code:
      struct
        {
          unsigned char aaa;
          volatile unsigned char bbb;
        } flags;
    
    the volatile qualifier on the second member of the struct 'flags' is ignored.

    Workaround:
    Apply the volatile qualifier to the entire struct.
      struct
        {
          unsigned char aaa;
          volatile unsigned char bbb;
        } volatile flags;
    
    (22483)
    MPLIB is unable to work with MPLAB C18 files compiled in the static overlay model.
    For example:
      int add( int a, int b )
      {
        int c;
        c = a + b;
        return c;
      }
    
    Compiled with:
      mcc18 test.c -sco
    
    Then placed in an archive containing only this file:
      mplib -c test.lib test.o
    
    MPLIB is unable to list the files in the archive.
      mplib -t test.lib
    
    Gives the error:
      Error - Coff file 'test.o' could not read string table.
      Error - Could not build member 'test.o' in library file 'test.lib'.
    
    Trying to use such an archive with MPLINK also gives an error saying it could not read the string table.

    Inline Assembly


    (21443)
    Compiler crashes on invalid inline assembly code.
    For example:
      void foo(unsigned short addr)
      {
        _asm
        movff ((unsigned char *)&addr)+1,1
        _endasm
      }
    
    The workaround is to use valid inline assembly syntax:
      movff addr+1,1
    
    (22557)
    In some cases, using a valid cast expression in inline assembly can cause a crash:
      void main (void)
      {
        static char x;
        _asm
          movff x, x + (unsigned char)1
        _endasm
      }
    
    The workaround is to remove the cast.

    (22170 / 22632)
    Incorrect use of automatic local variables in inline assembly code does not generate a warning or error.
    Automatic local variables, when used in inline assembly expressions, are given a value which is their offset from the frame pointer.
    For example, the following code demonstrates the proper accessing of stack-based variable 'a' using its value in PLUSW2 addressing.
    It then demonstrates improper accessing of stack variable 'b' by attempting to reference it using direct mode addressing.
      #include <p18f452.h>
      
      void assignlocals( void )
      {
        auto char a, b;
      
        _asm
      
        // correctly assigns TMR0L to variable 'a'
        movlw a
        movff TMR0L, PLUSW2
      
        // DOES NOT correctly assign TMR0L to variable 'b'
        movff TMR0L, b
      
        _endasm
      }
    
    The compiler should give an error (or at least a warning) on the use of variable 'b' in a direct mode addressing instruction, but it instead generates code as if the offset were an absolute address.


    (22559)
    Enumeration constants in expressions which are operands of inline assembly instructions can cause an internal error to be generated.
    The workaround is to use integer constants instead.

    Preprocessor


    (21817)
    Preprocessor merging operator should take precedence over the stringization operator.
    For example:
      #define STR(a) NXSTR(a)
      #define NXSTR(a) #a
    
      void
      foo (void)
      {
        // Apply "merging" operator
         #define CAT(a, b) NXCAT(a, b)
         #define NXCAT(a, b) a ## b
      
        // The two tokens '1.' and 'E9' should be merged into a single token
        // before the stringization operator is applied.
         STR(CAT (1., E9));
      }
    
    Preprocesses to:
      "CAT (1., E9)" ;
    
    but it should produce:
      "1.E9" ;
    
    (23817)
    The preprocessor performs macro replacement within the text of a #error directive.

    Example source code:
      #define FOSC 1800
      #error "FOSC is 1800"
    
    Preprocessor command line:
      cpp18 preproc-1.c
    
    Preprocessor output:
      #line 1 "preproc-1.c"
      #line 2 "preproc-1.c"
      preproc-1.c:2: "1800 is 1800"
    
    (23827)
    Crash (after error message) for #elif with no preceding #if For example:
      ...
      /* no #if here */
      #elif defined (_FOO_)
      #endif
    
    (23717 / 23844)
    Comments in a macro call may cause incorrect substitution or a syntax error.
    For example:
      #pragma romdata CONFIG
      _CONFIG_DECL (_OSCS_OFF_1H & _OSC_HSPLL_1H, // comments
      _PWRT_ON_2L & _BOR_OFF_2L & _BORV_42_2L,
      // comments
      0,
      _CCP2MUX_OFF_3H,
      ...
    
    Another example:

    A comment following the last argument in a macro invocation may cause a syntax error. For example:
      #include <p18f8720.h>
      #pragma romdata CONFIG
      _CONFIG_DECL
          (_CONFIG1H_DEFAULT,
           _CONFIG2L_DEFAULT,
           _CONFIG2H_DEFAULT,
           _CONFIG3L_DEFAULT,
           _CONFIG3H_DEFAULT,
           _CONFIG4L_DEFAULT,
           _CONFIG5L_DEFAULT,
           _CONFIG5H_DEFAULT,
           _CONFIG6L_DEFAULT,
           _CONFIG6H_DEFAULT,
           _CONFIG7L_DEFAULT,
           _CONFIG7H_DEFAULT //12
          );
      #pragma romdata
    
    The workaround is to not have comments inside a macro call.

    (24038)
    No error is given when #if does not have corresponding #endif and the condition is true
    For example:
    This gives a syntax error:
      #if defined(x)
      int y = x;
    
    But this does not:
      #define x 2
      #if defined(x)
      int y = x;
    
    Both should give syntax errors since the #endif is missing.

    (25409)
    Preprocessor evaluates expressions in discarded lines of an #ifdef expression.
    For example:
      #ifdef foo
      #if 12/foo
      #endif
      #endif
      ...
    
    Will generate a divide by zero error from the preprocessor, but should not since the expression shouldn't be evaluated.

    (22522)
    The preprocessor may go into an infinite loop when expanding mutually recursive macros.
    For example:
      #define x (4 + y)
      #define y (2 * x)
      void main (void) { y; }
    
    causes the preprocessor to run indefinitely.

    (21252 / 25868)
    A macro invocation spanning more than one logical source file line may throw off line number information, or cause the preprocessor to not output a line number, causing debugging difficulty in the MPLAB IDE.
    For example:
      void main (void)
      {
        int x;
    
        f (arg1,
           arg2,
           arg3); // macro call
        ...
        x++;      // breakpoint may not function correctly here
        ...
    
    A breakpoint set on a line following such a macro call may not work correctly. MPLAB IDE may state that such a breakpoint cannot be set.
    Additionally, stepping through the source code may not follow the expected sequence of execution. The workaround is to use the line splice character after each macro argument:
      void main (void)
      {
        int x;
    
        f (arg1,\
           arg2,\
           arg3);
        ...
        x++;
    
    (26031)
    The preprocessor performs macro replacement inside a #pragma directive.
    Macro replacement is performed inside any #pragma directive.

    The following code results in
      Error [1225] configuration value '0' not recognized for configuration setting 'WDT'
    
      #define OFF 0
      #define ON 1
    
      #pragma config WDT = OFF
      ....
    
    Workarounds:
    1) Move #pragma config to a separate .c source file with no #define or #include directives.
    2) Move #pragma config prior to any #define or #include directives.

    (26397)
    A constant string ending with \\" causes any following text on the line to be treated as part of the string
    The following code:
      char test[]="\\"; // "string"
    preprocessed with:
      mcc18 preproc.c -e
    results in:
      #line 1 "preproc.c"
       char test[]="\\"; // "string"
    Notice that the preprocessor does not remove the comment.

    (26385)
    The preprocessor does not throw an error on finding "#elsif"
    The following code:
      #define _BAR_
    
      #if defined(_FOO_)
        #error "_FOO_ defined"
      #elsif defined(_BAR_)
        #error "_BAR_ defined"
      #else
        #error "Neither defined"
      #endif
    will print "Neither defined" since "#elsif" is not a valid preprocessor directive. Although it should be "#elif" no error or warning is given about the typo.

    (25733)
    Using the absolute path in a "#include" directive causes the compiler to use an invalid filepath in the COFF file and error messages.
    Example source file:
      #include "c:\test\c18\include\header.h"
      void main (void)
      {}
    
    compiled with --
      c:\test\c18\include>mcc18 includepath.c
    
    causes the following path in the COFF file --
      C:\test\c18\include\c:\test\c18\include\header.h
    The path appears to be the included file's absolute path appended to the current working directory.
    and if the included file contains an error, the error messages show --
      C:\test\c18\include\c:\test\c18\include\header.h:1:Error: syntax error
    
    (27540)
    A malformed expression in a #if preprocessor directive on the last line of a file with no terminating end of line character may cause the preprocessor to crash.
    For example:
      #define symbol
      #if symbol /* end of file */
    
    causes the preprocessor to crash.

    Workaround: Terminate the source file by adding a blank last line.
    The preprocessor will display an error without crashing.

    (27541)
    #undef on the last line of a source file with no terminating end of line character may cause the preprocessor to crash.
    The following source file:
      #include <p18cxxx.h>
      
      void  main(void)
      {
         while(1);
      }
      
      #undef  SOME_LABEL /* end of file */
    
    causes the preprocessor to crash.

    Workaround: Terminate the source file by adding a blank last line.
    (28101)
    Circular or recursive macro defnitions can cause the preprocessor to take up all available CPU cycles and hang for a long time before giving an error.
    For example, the following code:
      void main(void)
      {
        #define f g
        #define g f
        f(1);
      }
    
    causes the preprocessor to hang for a long time, then give an error similar to:
      Preprocessor Error : out of dynamic memory in yy_scan_buffer
    

    Libraries

    Note: From the release of MPLAB C18 v2.42 onward, no support has been or will be added to the peripheral libraries.

    (18624)
    The library routine 'atof' generates a result less precise than simply assigning a constant. For example:
      float a, c;
      char b[] = ".15625";
      void main ( )
      {
        a = atof (b);
        c = .15625;
      }
    
    The representation of 'c' is 0x7c200000 and 'a' is 0x7c1fffff.

    (23497)
    Timer5, SPI, and I2C peripherals not implemented for 18F2331, 18F2431, 18F4331, and 18F4431; nor is the enhanced facility (function baudUSART) implemented for these devices.
    The peripheral libraries do not currently support these peripherals on these devices.

    (26882)
    Library c018iz.o does not zero bank 15 at startup.
    Workarounds:
    Modify the startup code to point FSR0 to the highest general purpose RAM location.
    Specifically zero the variables located in bank 15.

    Header Files


    None.

    User Error Screening

    (26595)
    Utilizing an enumerated type for a bitfield does not cause an error diagnostic to be issued.
    The following code does not issue an error diagnostic:
      enum test_enum {alphavar, betavar, gammavar, deltavar = 5, epsilonvar};
      typedef struct {
        enum test_enum S_FH_FT : 3;
      } _c_LsFH_FT_1_msgType;
    
  11. Contributors

    Microchip gratefully acknowledges the contributions of the following to the development of MPLAB C18.

    Daniel Madill, Quanser Consulting --
    December 2000, Optimizations to fixed point divide library routines.

  12. Customer Support


    Microchip provides online support via our home page at:
    http://www.microchip.com

    Technical support is available through the web site at:
    http://support.microchip.com

    A forum for discussion of Microchip products and tools is available at:
    http://forum.microchip.com