Hot!xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib.h

Author
glenntrimble
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2018/06/18 14:26:12
  • Location: 0
  • Status: offline
2018/07/10 09:01:59 (permalink)
0

xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib.h

After compiling successfully (no errors)
, I notice a squiggly line under the #include <xc.h> in the .c source file.
 
Holding down the Ctrl key and mousing over it, the following message appears:
 
Library File C:\Program Files (x86)\Microchip\xc8\v2.00\pic\include\xc.h
but there is an unresolved #include <alloca.h>
in included C:\Program Files (x86)\Microchip\xc8\v2.00\pic\include\c99\stdlib.h
 
Is this something to be concerned about or is this a WIP for the v2 compiler.
 
Thanks,
Glenn
#1

15 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 2546
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/07/10 10:01:45 (permalink)
    +2 (2)
    Using a heap on a small PIC doesn't make much sense, so you can easily get away with that.
     
    Looks as if Microsoft is starting to "equalize" AVR/ATmega and PIC1x devices as far as possible. The support for *alloc() /*free() of all flavours might come from the Atmel tool chain which is somewhat different due to significant architectural differences.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    jtemples
    Super Member
    • Total Posts : 11099
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/07/10 10:14:52 (permalink)
    +4 (4)
    Using a heap

     
    alloca does not use a heap and is not related to malloc/free.  It allocates from the stack and automatically releases the storage when exiting the function from which it's called.  It's not a standard C function (it comes from the UNIX world), and I don't know if it's even supported in XC8.
    #3
    davekw7x
    Entropy++
    • Total Posts : 1692
    • Reward points : 0
    • Joined: 2012/01/16 12:01:07
    • Location: Left Coast, USA
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/07/10 10:20:49 (permalink)
    +3 (3)
    Important "features" to note:
    1. Ignore red squiggly lines under header files and under device definitions.  They come and go when you build a project and when you exit MLABX and re-enter, and when you forgot to bury a chicken's head under your rear porch step at midnight on Summer Solstice, and for a few other unspecified and, generally, unknowable, unpredictable, and unrepeatable conditions.

      This is a "problem" that has been brought to light time after time after time on this forum.  It is a Netbeans (created by for and of Java Programmers) thing. There is no proven workaround.

      Just create a "real" program and try to compile.  If the compiler is unhappy, it will tell you specifically what is wrong.  (Sometimes after you compile the red squigglies go away, only to return at some unspecified time in the future.)

      My suggestion: Grit your teeth and bear it.  Then try some meditation technique to help you not to grit your teeth so much.  (That is what Works For Me)
    2. The place in <stdlib.h> where it includes <alloca.h> is delimited by some conditional compiler preprocessor statements, and will not be part of any "normal" XC8 compilations.
    3. There is no <alloca.h> in the XC8 version 2.00 distribution so you couldn't use it even if you wanted to.  And you shouldn't want to: du00000001 gives Good Advice.  Well, actually, as jtemples points out, GNU alloca doesn't use the heap, but it still would be a Bad Idea (in my opinion) for an small PIC---like the ones covered by XC8.
     
    Regards,
     
    Dave
    post edited by davekw7x - 2018/07/10 10:39:09

    Sometimes I just can't help myself...
    #4
    du00000001
    Just Some Member
    • Total Posts : 2546
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/07/10 12:39:42 (permalink)
    +2 (2)
    @ jtemples
    I'm ever learning...
    Although - with a compiled stack it might be somewhat hard to alloca() then wink
    Considering it should be in some header file, it is either intended to be used by the user or by some service routine. None of these highly desirable.

    I've checked previous versions (1.3x, 1.45): none of these incorporates such a file, although they sport calloc() and a bit more in one of the headers. Plus the corresponding *free() routines.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #5
    jack@kksound
    code tags!
    • Total Posts : 3156
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/07/10 13:21:25 (permalink)
    0
    Also this issue appears to only occur (at least for me) when the c99 standard is selected, selecting c90 it does not appear. Neither case actually trips a compiler error or warning, only the red squiggles. MPLAB X!
    #6
    jtemples
    Super Member
    • Total Posts : 11099
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/07/10 13:28:14 (permalink)
    +1 (1)
    I have a vague memory of the original Hi-Tech compiler having an x86 version; maybe that's where alloca came from.
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 17129
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/07/10 13:58:16 (permalink)
    +1 (1)
    Since there really in no "the Stack" in XC8 I am not sure how they would implement this.  Possibly it could work in simulated Stack mode.
    But in general how is it more useful than a local variable?
    #8
    jtemples
    Super Member
    • Total Posts : 11099
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/07/10 14:03:31 (permalink)
    +2 (2)
    But in general how is it more useful than a local variable?

     
    That would require you to know the required size ahead of time.  And this has the additional advantage of not being able to cause memory leaks like malloc, since you don't need to explicitly free.
    #9
    erenard
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2017/11/27 06:22:17
    • Location: 0
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/09/11 11:28:22 (permalink)
    -1 (1)
    So, this may not be the best way to go about it, but I was able to locate the alloca.h file in Microchip/xc8/v2.00/avr/avr/include and copy/paste it to somewhere MPLAB was already looking in /xc8/v2.00/pic/include.
     
    I don't have a good way to test if that works, but maybe someone else does.
    #10
    gabe.mihu
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/09/27 12:00:11 (permalink)
    0
    Same issue here, had to play with C90/C99 options. Customer service slow to respond. After installing 2.00, everything was messed up, most "includes" not working... very frustrated, slows down work at my company. It should come with a warning sign.
    #11
    jack@kksound
    code tags!
    • Total Posts : 3156
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/09/28 09:47:24 (permalink)
    +3 (3)
    gabe.mihu
    Same issue here, had to play with C90/C99 options. Customer service slow to respond. After installing 2.00, everything was messed up, most "includes" not working... very frustrated, slows down work at my company. It should come with a warning sign.


    Warning sign? Did you read the release notes?
    #12
    NKurzman
    A Guy on the Net
    • Total Posts : 17129
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/09/28 16:15:24 (permalink)
    +1 (1)
    There is a reason they did not jump to C99 20 years ago.  
    Not everyone will want C99 
    #13
    JPortici
    Super Member
    • Total Posts : 623
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/09/29 00:42:22 (permalink)
    +1 (1)
    jack@kksound
    gabe.mihu
    Same issue here, had to play with C90/C99 options. Customer service slow to respond. After installing 2.00, everything was messed up, most "includes" not working... very frustrated, slows down work at my company. It should come with a warning sign.


    Warning sign? Did you read the release notes?




    Of course he didn't. Apparently nobody does :(
    post edited by JPortici - 2018/09/29 01:33:04
    #14
    glenntrimble
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/06/18 14:26:12
    • Location: 0
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/11/16 08:06:40 (permalink)
    0
    jack@kksound, gabe.mihu


    Turns out that I needed to select C90 and use the C90 library when compiling
    the source with XC8 v2.0. There was a bug with MPLABS X that would not preserve
    the library selection. This has been fixed in the MPLABS X v5.05 release.

    Prior to 5.05, this is a work-around:


    Select C99 standard in linking library standard
    (Note: this will not pass any exclusive -mc option to linker.)
    Add '-mc90lib' under additional options in linker. This will link in
    C90 library and the option will be retained in properties.


    #15
    dave_blackcat
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2016/11/16 00:28:19
    • Location: 0
    • Status: offline
    Re: xc8 v2 - unresolved #include <alloca.h> in included .\xc8\v2.00\pic\include\c99\stdlib 2018/11/17 18:54:55 (permalink)
    0
    Passing a linker option is an idea.
     
    The alloca.c file is absent, comment out the line from stdlib.h.
    Or add an empty pic/include/c99/alloca.h header. 
     
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5