I have a few issues with C++ headers in 11.2.1 from .cpp files:
1) #include <algorithm> / <cstddef> gives a warning in the editor (shown in the gutter) saying its an unresolved include although the project builds fine.
2) If <xs1.h> is included before <algorithm> then you can't include <algorithm> as you get an error about a re-declaration of clock_t
Neither are major as I can work around both but the first is just an annoyance in the editor and for the second, it means re-defining items from xs1.h myself rather than using it (for defines such as XS1_TIMER_HZ etc).
Cheers
Russell
Issues using C++ headers
-
- Junior Member
- Posts: 6
- Joined: Fri Jun 17, 2011 9:31 am
-
- Respected Member
- Posts: 318
- Joined: Tue Dec 15, 2009 12:46 am
Problem 2) is hard to avoid since xs1.h defines the clock type which clashes with the declaration of the clock() function in clock.h included indirectly from <algorithm>. Renaming either of these isn't really an option (clock() is part of the C standard and renaming the clock type would break lots of XC code).rhind wrote:2) If <xs1.h> is included before <algorithm> then you can't include <algorithm> as you get an error about a re-declaration of clock_t
Neither are major as I can work around both but the first is just an annoyance in the editor and for the second, it means re-defining items from xs1.h myself rather than using it (for defines such as XS1_TIMER_HZ etc).
Another workaround is as follows:
This avoids the need to copy definitions out of xs1.h.#define clock __clock
#include <xs1.h>
#undef clock
#include <algorithm>
-
- Junior Member
- Posts: 6
- Joined: Fri Jun 17, 2011 9:31 am
Thanks, I may try this but for now I think its easier to duplicate the stuff I need out of xs1.h in to my own header that doesn't declare the clock stuff.#define clock __clock
#include <xs1.h>
#undef clock
#include <algorithm>
A shame the XC types couldn't be prefixed with xc_ or something to try and avoid conflicts with standard C/C++ stuff.
Cheers
Russell
-
- XCore Expert
- Posts: 844
- Joined: Sun Jul 11, 2010 1:31 am
There aren't any conflicts with standard C stuff.rhind wrote:A shame the XC types couldn't be prefixed with xc_ or something to try and avoid conflicts with standard C/C++ stuff.