Author Topic: Precompiled header gives me error: stray 216  (Read 11904 times)

Offline smallB

  • Almost regular
  • **
  • Posts: 193
Precompiled header gives me error: stray 216
« on: October 28, 2011, 09:46:02 am »
Guys, after precompiling a file (any file but included below some sample code) and including it via build options, I'm getting an error: stray 216. What is the cause of it?
I tried gcc 4.6 and gcc 4.6.1 and the result is the same.
Code
#ifndef IS_CHAR_H_INCLUDED
#define IS_CHAR_H_INCLUDED
#include <type_traits>

template<class Int_T>
struct Is_Char_
{
enum {value = false};
};

template<>
struct Is_Char_<char>
{
    enum {value = true};
};

template<>
struct Is_Char_<unsigned char>
{
    enum {value = true};
};

template<>
struct Is_Char_<signed char>
{
    enum {value = true};
};

template<class Int_T>
struct Is_Char : Is_Char_<typename std::remove_cv<Int_T>::type>
{

};

#endif // IS_CHAR_H_INCLUDED

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Precompiled header gives me error: stray 216
« Reply #1 on: October 28, 2011, 09:59:19 am »
What is the cause of it?
Works fine here. Probably a wrong encoding on your side?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline smallB

  • Almost regular
  • **
  • Posts: 193
Re: Precompiled header gives me error: stray 216
« Reply #2 on: October 28, 2011, 10:41:13 am »
Try to precompile this:
Code
#ifndef PROMOTE_H_INCLUDED
#define PROMOTE_H_INCLUDED
#include <type_traits>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/end.hpp>
#include "Is_Char.h"
template<class Integer>
struct Promote
{
    static_assert(std::is_integral<Integer>::value,"Non Integer type is not allowed.");
/*Check correct type - depending on Integer being signed or unsigned*/
    typedef typename std::conditional<std::is_signed<Integer>::value,
                                boost::mpl::vector<signed char,short,int,long,long long>,
    boost::mpl::vector<unsigned char,unsigned short,unsigned int,long,long long>
>::type types;
/*Find this type from the list above - substituting Integer for signed or unsigned char iff Integer is of type char*/
    typedef typename boost::mpl::find<types,
    typename std::conditional<Is_Char<Integer>::value,
    typename std::conditional<std::is_signed<Integer>::value,signed char,unsigned char>::type, Integer>::type>::type this_type;

/*If Integer is int and if size of it is == to long promote int to long long (iterate to next element twice)*/
typedef typename boost::mpl::eval_if<boost::mpl::bool_<((std::is_same<Integer,int>::value || std::is_same<Integer,unsigned int>::value)
&& (sizeof(int) == sizeof(long)))>,
boost::mpl::next<typename boost::mpl::next<this_type>::type>,
boost::mpl::next<this_type>
>::type next_type;
/*Check if iterator points within range or if one pass end which means that Integer was u/long long*/
typedef typename std::conditional<std::is_same<typename boost::mpl::end<types>::type,next_type>::value,Integer,typename boost::mpl::deref<next_type>::type>::type type;
};

#endif // PROMOTE_H_INCLUDED

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Precompiled header gives me error: stray 216
« Reply #3 on: October 28, 2011, 10:46:12 am »
Hm, have you tried to precompile from the command line, without using C::B?
If you have and it failed, too. Then your problem is in the compiler, not C::B.
You're using an experimental mode for the compiler and also you're pushing the limits by using TMP and boost...

p.s. Please don't post in this subforum if you are not posting patches or requests for help on developing a feature for C::B! This subforum is not for users of C::B, but developers (official or not)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Precompiled header gives me error: stray 216
« Reply #4 on: October 28, 2011, 12:15:44 pm »
Try to precompile this:
Doesn't work because of missing includes (Is_Char).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline smallB

  • Almost regular
  • **
  • Posts: 193
Re: Precompiled header gives me error: stray 216
« Reply #5 on: October 28, 2011, 05:18:15 pm »
Guys, first answer to your question:
Yes, I did succeed with precompiling this file via command line, that's why I'm baffled why I cannot do this with cb (same compiler parameters).
@Morgen "Is_Char.h" is the first file posted here on this thread.
Anyway here is my question:
I have precompiled file called Promote.h. The resulting file has name Promote.h.gch. I've created completely new project and've pasted in this project directory this precompiled header. When I try to use this class from this precompiled header it gets compiled again (although unsuccessfully - the only way I can successfully precompile it is via command line). So this file despite the fact being precompiled gets compiled again (I see the output on build messages window) and this compilation cannot successfully finished. I'm getting tons of warnings, no error is listed.
My question is:
1. Is that correct behaviour of cb? Why the precompiled header gets (and how?) compiled again?
2. Why this file compiles successfully via command line but not via IDE? The same params are sent via command line (I just copy them from a build log).
3. Is there a way to make cb not compile it and just use this precompiled header?
Regards  
@Obfuscated, sorry for posting here, I didn't now where to post it, could you please tell me, so next time I know the correct place.
« Last Edit: October 28, 2011, 05:48:13 pm by smallB »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Precompiled header gives me error: stray 216
« Reply #6 on: October 28, 2011, 06:05:29 pm »
@Obfuscated, sorry for posting here, I didn't now where to post it, could you please tell me, so next time I know the correct place.
Every (almost) subforum has a sticky topic at the top explaining the purpose of the subforum.

Have you enabled the full log when compiling?
If not enable it and compare the two logs (the one from C::B and the one from your console).
Then copy the commands from C::B and try to make them work.
After that you can tell us what is needed in order to make it work in C::B.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline smallB

  • Almost regular
  • **
  • Posts: 193
Re: Precompiled header gives me error: stray 216
« Reply #7 on: October 30, 2011, 02:14:20 pm »
@Obfuscated well, few issues:
1. My bad, in build options I've had -include "Promote.h.gch" instead of "Promote.h" - that was the cause of stray 216 error. This is sorted now.
2. In order to compile this I had to disable few switches - notably pedantic errors + few others. It compiles for me with just -Wall and -Wextra. That is sorted now.
3. Even though I have this file precompiled it is still being compiled every time I press f9. Why? The whole purpose of precompiling is to have it done once and for all. So this ISN'T sorted and I would ask you guys to help me with this.
Thanks.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Precompiled header gives me error: stray 216
« Reply #8 on: October 30, 2011, 05:17:45 pm »
3. Even though I have this file precompiled it is still being compiled every time I press f9. Why?
If the header was precompiled with different options than the rest of the project, gcc will not use it.  Try a full rebuild.

Offline smallB

  • Almost regular
  • **
  • Posts: 193
Re: Precompiled header gives me error: stray 216
« Reply #9 on: October 30, 2011, 08:00:41 pm »
@Alpha thanks, will try.