Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

include right Headers

134 views
Skip to first unread message

tok...@gmail.com

unread,
Jul 25, 2016, 12:40:46 PM7/25/16
to
Hi everybody,

I have a little class hierachy:

|Base|
|
|Sub|
/ \
|Sub2| |Sub3|

Here's my main-code:

1 #include "Sub2.h"
2 //#include "Sub3.h"
3
4
5 int main () {
6
7 Sub sub("thomas", 53);
8 cout << sub.getMsg() << endl;
9
10 Sub2 sub2 ("Thomas", 53, "Deutschland");
11 cout << sub2.getMsg() << endl;
12
13 //Sub3 sub3 ("Thomas", 53, "Deutschland", "Male");
14 //cout << sub3.getMsg() << endl;
15
16 return EXIT_SUCCESS;
17 }


This works fine. But when I include Sub3.h and delete the comments from Sub3 sub3 then I get errors:

In file included from Sub.h:1:0,
from Sub3.h:1,
from main.cpp:2:
Base.h:3:7: error: redefinition of ‘class Base’
class Base {
^
In file included from Sub.h:1:0,
from Sub2.h:1,
from main.cpp:1:
Base.h:3:7: error: previous definition of ‘class Base’
class Base {
^
In file included from Sub3.h:1:0,
from main.cpp:2:
Sub.h:4:7: error: redefinition of ‘class Sub’
class Sub : public Base {
^
In file included from Sub2.h:1:0,
from main.cpp:1:
Sub.h:4:7: error: previous definition of ‘class Sub’
class Sub : public Base {








Paavo Helde

unread,
Jul 25, 2016, 2:12:14 PM7/25/16
to
You need to protect your header files against multiple inclusion.
Nowadays in practice it is just OK to put in the start of each header file:

#pragma once


red floyd

unread,
Jul 25, 2016, 2:12:27 PM7/25/16
to
On 7/25/2016 9:40 AM, tok...@gmail.com wrote:
> Hi everybody,
>
> I have a little class hierachy:
>
> |Base|
> |
> |Sub|
> / \
> |Sub2| |Sub3|
>
> Here's my main-code:
>
[redacted]

Search google for "Include Guards". Learn them. Use them.

Also, if you are going to post sample code, you need to include
your headers.



tok...@gmail.com

unread,
Jul 25, 2016, 3:01:21 PM7/25/16
to
Oh my god. I know this rule and I forget it;-). Thank you.

Jerry Stuckle

unread,
Jul 25, 2016, 3:14:09 PM7/25/16
to
Just beware that not all compilers support #pragma once. However, all
standards compliant compilers support include guards, i.e.

#ifndef __SUB3_H_INCLUDED
#define __SUB3_H_INCLUDED
.... file goes here
#endif

Where __SUB3_H is unique to the compilation (to keep things simple I
always have it related to the header file name).

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

Alf P. Steinbach

unread,
Jul 25, 2016, 3:58:13 PM7/25/16
to
On 25.07.2016 21:14, Jerry Stuckle wrote:
>
> Just beware that not all compilers support #pragma once.

There is a list in Wikipedia.

In practice, a compiler that doesn't support `#pragma once` is one that
quite likely also has many other quirks, i.e. not a good idea to use it.


> However, all standards compliant compilers support include guards, i.e.
>
> #ifndef __SUB3_H_INCLUDED
> #define __SUB3_H_INCLUDED
> .... file goes here
> #endif
>
> Where __SUB3_H is unique to the compilation (to keep things simple I
> always have it related to the header file name).
>

Note: the name `__SUB3_H` is reserved to the implementation because it
has two successive underscores; i.e. this code is non-portable.

It would also be reserved if it started with underscore followed by
uppercase.

And in the global namespace it would be reserved if it just started with
underscore.


Cheers & hth.,

- Alf

Jerry Stuckle

unread,
Jul 25, 2016, 4:08:17 PM7/25/16
to
On 7/25/2016 3:56 PM, Alf P. Steinbach wrote:
> On 25.07.2016 21:14, Jerry Stuckle wrote:
>>
>> Just beware that not all compilers support #pragma once.
>
> There is a list in Wikipedia.
>
> In practice, a compiler that doesn't support `#pragma once` is one that
> quite likely also has many other quirks, i.e. not a good idea to use it.
>

Perhaps, perhaps not. That's a pretty broad statement. Nothing in the
standard requires #pragma once be supported.

>
>> However, all standards compliant compilers support include guards, i.e.
>>
>> #ifndef __SUB3_H_INCLUDED
>> #define __SUB3_H_INCLUDED
>> .... file goes here
>> #endif
>>
>> Where __SUB3_H is unique to the compilation (to keep things simple I
>> always have it related to the header file name).
>>
>
> Note: the name `__SUB3_H` is reserved to the implementation because it
> has two successive underscores; i.e. this code is non-portable.
>
> It would also be reserved if it started with underscore followed by
> uppercase.
>
> And in the global namespace it would be reserved if it just started with
> underscore.
>
>
> Cheers & hth.,
>
> - Alf
>

So, use some other identifier. This was an example.

But show me where this particular example DOESN'T work.

Vir Campestris

unread,
Jul 25, 2016, 4:19:30 PM7/25/16
to
On 25/07/2016 20:56, Alf P. Steinbach wrote:
> On 25.07.2016 21:14, Jerry Stuckle wrote:
>>
>> Just beware that not all compilers support #pragma once.
>
> There is a list in Wikipedia.
>
> In practice, a compiler that doesn't support `#pragma once` is one that
> quite likely also has many other quirks, i.e. not a good idea to use it.

I used to work in somewhere we aimed at portable code. We included
_both_ the include guards and the #pragma - the guards always work, but
the #pragma may be faster - Visual Studio's compiler at the time didn't
even _open_ the file on the second occurrence, never mind parse it.

Andy
--
Oh. It says that in Wikipedia...
https://en.wikipedia.org/wiki/Pragma_once

red floyd

unread,
Jul 25, 2016, 6:50:13 PM7/25/16
to
It doesn't matter where this particular example DOESN'T work. It's in
violation of the Standard. Any vendor is free in the future to create
a #define __SUB3_H_INCLUDED, which will break your code.

My personal usage for include guards is FILE_H_



Jerry Stuckle

unread,
Jul 25, 2016, 10:33:13 PM7/25/16
to
As I said - it was an EXAMPLE. But you also can't show where it DOESN'T
WORK.

David Brown

unread,
Jul 26, 2016, 4:20:37 AM7/26/16
to
On 25/07/16 22:19, Vir Campestris wrote:
> On 25/07/2016 20:56, Alf P. Steinbach wrote:
>> On 25.07.2016 21:14, Jerry Stuckle wrote:
>>>
>>> Just beware that not all compilers support #pragma once.
>>
>> There is a list in Wikipedia.
>>
>> In practice, a compiler that doesn't support `#pragma once` is one that
>> quite likely also has many other quirks, i.e. not a good idea to use it.
>
> I used to work in somewhere we aimed at portable code. We included
> _both_ the include guards and the #pragma - the guards always work, but
> the #pragma may be faster - Visual Studio's compiler at the time didn't
> even _open_ the file on the second occurrence, never mind parse it.
>

I haven't tried any benchmarks, but according to the Wikipedia page many
compilers (such as gcc, clang, icc, and MSVC) have optimisations to make
simple #include guards as fast as possible. Of course, that is for
current compilers - it is quite possible that #pragma once was faster
when you were doing this work.

I don't think there will be any direct harm in using both methods, but
the standard #include guard will be supported by IDE's, programmers'
editors, linters, build utilities, or any other tool that does basic C
pre-processing on files. Such tools are less likely to support #pragma
once.

So if you first have the #include guards, and using #pragma once makes
little speed difference in practice (I have no benchmarks to confirm
this, and it may vary between compilers), then the #pragma is
superfluous and it is potentially confusing to have two different
methods of doing the same thing in the code.

Perhaps one day we will get a single standardised module system for C++,
and this will all be a thing of the past...

Juha Nieminen

unread,
Jul 26, 2016, 5:49:09 AM7/26/16
to
David Brown <david...@hesbynett.no> wrote:
> Perhaps one day we will get a single standardised module system for C++,
> and this will all be a thing of the past...

Objective-C(++) has the #import directive. If the same file is #imported
a second time during the compilation of a file, it's completely skipped.

I have found #import to be quite practical because it saves you from
having to write any inclusion guards at all.

(If there are some rare circumstances where you really *need* to
include a file twice, eg. to replicate the same data in two places,
you can still use #include for that.)

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

D Laboratory

unread,
Jul 26, 2016, 7:27:16 AM7/26/16
to

>
> Just beware that not all compilers support #pragma once. However, all
> standards compliant compilers support include guards, i.e.
>
> #ifndef __SUB3_H_INCLUDED
> #define __SUB3_H_INCLUDED
> .... file goes here
> #endif
>
> Where __SUB3_H is unique to the compilation (to keep things simple I
> always have it related to the header file name).
>

There is a list on Wikipedia
(https://en.wikipedia.org/wiki/Pragma_once). Almost all popular C++
compilers support this feature, including LLVM/Clang, Comeau C/C++,
C++Builder XE3, Digital Mars C++, GCC, HP C/aC++, IBM XL C/C++, Intel
C++ Compiler, Microsoft Visual C++, Pelles C, ARM DS-5, IAR C/C++. On
that list, only Solaris Studio C/C++ doesn't support #pragma once syntax.

For people using Windows, Linux or OS X, there is no doubt the compiler
supports it. On those platforms, 4 popular C++ compilers, GCC, clang,
MSVC, ICC, they are all compatible with this syntax.

The #ifndef .. #define .. #endif guards cost compile time, and the
programmer also needs to avoid macro name conflicts, so I suggest
programmers use #pragma once.

Jerry Stuckle

unread,
Jul 26, 2016, 12:35:12 PM7/26/16
to
And there are many compilers which do NOT support #pragma once - I use
some on embedded systems. And these are popular compilers in their
market.

Also, most compilers which support #pragma once also can optimize the
header guards.

And there is no problem with macro name conflicts if one uses macro
names relating to the file name - as in my suggestion.

But since #pragma once is not part of the standard, it is not required
to be supported by any standards-compliant compiler, and it can be
dropped at any time.

red floyd

unread,
Jul 26, 2016, 1:12:38 PM7/26/16
to
On 7/26/2016 9:35 AM, Jerry Stuckle wrote:

>
> But since #pragma once is not part of the standard, it is not required
> to be supported by any standards-compliant compiler, and it can be
> dropped at any time.
>

Now you're being inconsistent. You're complaining that #pragma once is
not part of the Standard and can be dropped at any time. Yet, you say
that using names reserved for the Standard is OK, because you can't find
a single compiler that it causes a conflict.

Pick one. Either stick with the Standard or don't. But be consistent.

Jerry Stuckle

unread,
Jul 26, 2016, 2:45:40 PM7/26/16
to
I just asked you where my suggestion would fail. But you can't answer
that, can you?

Geoff

unread,
Jul 26, 2016, 3:12:48 PM7/26/16
to
This practice of using double underscores in user code is cargo cult
due in part to uninformed advice such as the above and in part due to
users who have peeked at the headers in their implementations where
this is allowed. Because they see it in the implementation where it is
quite properly used they think it's proper to use it in their code.

Jerry Stuckle

unread,
Jul 26, 2016, 3:35:58 PM7/26/16
to
That still doesn't answer my question. Show me where this particular
example DOESN'T work.

You can't, so you try to evade the question.

Geoff

unread,
Jul 26, 2016, 10:32:53 PM7/26/16
to
It doesn't matter where it doesn't work. It's bad practice given the
simplicity of the correct method and that method is standard compliant
and GUARANTEED to work correctly ALWAYS, there is absolutely no reason
not to name your include guard portably and correctly and keep your
symbols within their proper name space.

Modern practice dictates that contemporary advice should advise
against leading underscores followed by an uppercase letter since this
has been reserved to the implementation for many years.

Usage such as you advise is bad practice in the face of the standard,
your insistence on that usage is ill-advised and makes you a
propagator of cargo cult. It also marks you as ignorant of modern,
correct practices.

Jerry Stuckle

unread,
Jul 26, 2016, 11:39:36 PM7/26/16
to
I never said it was good practice. I just want you to show where it fails.

And BTW - there is nothing wrong with the "cargo cult" as you call it.
It is used by a number of large companies as part of their programming
style. But then they've also been doing it for over 30 years and see no
reason to go back and change all that code due to a standards change
which doesn't affect them. And these are not small companies - you
would most probably recognize every one I am thinking of - including
some big ones in the computer field.

That's why I want you to show where it fails.

Ian Collins

unread,
Jul 27, 2016, 1:50:32 AM7/27/16
to
On 07/27/16 03:39 PM, Jerry Stuckle wrote:
> On 7/26/2016 5:48 PM, Geoff wrote:
>>
>> It doesn't matter where it doesn't work. It's bad practice given the
>> simplicity of the correct method and that method is standard compliant
>> and GUARANTEED to work correctly ALWAYS, there is absolutely no reason
>> not to name your include guard portably and correctly and keep your
>> symbols within their proper name space.
>>
>> Modern practice dictates that contemporary advice should advise
>> against leading underscores followed by an uppercase letter since this
>> has been reserved to the implementation for many years.
>>
>> Usage such as you advise is bad practice in the face of the standard,
>> your insistence on that usage is ill-advised and makes you a
>> propagator of cargo cult. It also marks you as ignorant of modern,
>> correct practices.
>>
>
> I never said it was good practice. I just want you to show where it fails.

It'll fail when, as it is entitled to do, your implementation introduces
a conflicting symbol in its reserved namespace.

--
Ian

Jerry Stuckle

unread,
Jul 27, 2016, 8:54:05 AM7/27/16
to
So, you should be able to show where it fails then.

Mr Flibble

unread,
Jul 27, 2016, 12:23:39 PM7/27/16
to
Compilation will fail where it tries to compile anything defined in your
header that was skipped because your header guard was defined by the
implementation in one of its header files that you included (either
directly or indirectly) before your header file.

/Flibble

Mr Flibble

unread,
Jul 27, 2016, 12:26:22 PM7/27/16
to
Or alternatively compilation will fail where it tries to compile
anything defined in the implementation's header files that was skipped
because it used the same header guard as your header guard in your
header file was included before the implementation's header file was
included (either directly or indirectly).

/Flibble


Paavo Helde

unread,
Jul 27, 2016, 3:02:09 PM7/27/16
to
Concrete examples (MSVC2103):

// File PeopleConcert.h
#ifndef _PPLCONCRT_H
#define _PPLCONCRT_H
class PeopleConcert {
public:
void Organize() {}
};
#endif


// File main.cpp
#include <future>
#include "./PeopleConcert.h"

int main() {

PeopleConcert concert;
concert.Organize();

}

1> main.cpp
1>main.cpp(6): error C2065: 'PeopleConcert' : undeclared identifier
1>main.cpp(6): error C2146: syntax error : missing ';' before identifier
'concert'
1>main.cpp(6): error C2065: 'concert' : undeclared identifier
1>main.cpp(7): error C2065: 'concert' : undeclared identifier
1>main.cpp(7): error C2228: left of '.Organize' must have class/struct/union
1> type is 'unknown-type'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Alternatively:

// File PeopleConcert.h
#ifndef _PPLCONCRT_H
#define _PPLCONCRT_H

class PeopleConcert {
public:
void Organize() {}
};
#endif

// File main.cpp
#include "./PeopleConcert.h"
#include <future>

int main() {
PeopleConcert concert;
concert.Organize();
}

1> main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(132): error C2146: syntax error : missing ';'
before identifier 'task_status'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(132): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(190): error C3083: 'details': the symbol to
the left of a '::' must be a type
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(190): error C3083: '_TaskCollection_t': the
symbol to the left of a '::' must be a type
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(190): error C2039:
'_Is_cancellation_requested' : is not a member of 'Concurrency'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(190): error C3861:
'_Is_cancellation_requested': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(205): error C3861: 'task_canceled':
identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(243): error C3083: 'platform': the symbol to
the left of a '::' must be a type
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(243): error C2039: 'CaptureCallstack' : is
not a member of 'Concurrency::details'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(243): error C3861: 'CaptureCallstack':
identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(533): error C2061: syntax error : identifier
'_TaskInliningMode_t'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(535): error C2653: '_TaskCollection_t' : is
not a class or namespace name
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(535): error C3861: '_RunTask': identifier not
found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(535): error C2065: '_InliningMode' :
undeclared identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(936): error C2146: syntax error : missing ';'
before identifier '_M_exceptionObserved'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(936): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(896): error C2614:
'Concurrency::details::_ExceptionHolder' : illegal member
initialization: '_M_exceptionObserved' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(909): error C2065: '_M_exceptionObserved' :
undeclared identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(914): error C3861:
'_REPORT_PPLTASK_UNOBSERVED_EXCEPTION': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(920): error C2065: '_M_exceptionObserved' :
undeclared identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(922): error C2065: '_M_exceptionObserved' :
undeclared identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(922): error C3861: 'atomic_exchange':
identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1215): error C2061: syntax error : identifier
'cancellation_token'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1215): error C2535:
'Concurrency::task_options::task_options(void)' : member function
already defined or declared
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1203) : see declaration of
'Concurrency::task_options::task_options'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1239): error C2061: syntax error : identifier
'cancellation_token'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1239): error C2535:
'Concurrency::task_options::task_options(void)' : member function
already defined or declared
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1203) : see declaration of
'Concurrency::task_options::task_options'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1252): error C2039: 'shared_ptr' : is not a
member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1252): error C2061: syntax error : identifier
'shared_ptr'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1264): error C2061: syntax error : identifier
'scheduler_interface'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1264): error C2535:
'Concurrency::task_options::task_options(void)' : member function
already defined or declared
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1203) : see declaration of
'Concurrency::task_options::task_options'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1276): error C2061: syntax error : identifier
'scheduler_ptr'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1276): error C2535:
'Concurrency::task_options::task_options(void)' : member function
already defined or declared
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1203) : see declaration of
'Concurrency::task_options::task_options'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1300): error C2061: syntax error : identifier
'cancellation_token'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1325): error C2146: syntax error : missing
';' before identifier 'get_cancellation_token'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1325): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1326): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1328): warning C4183:
'get_cancellation_token': missing return type; assumed to be a member
function returning 'int'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1349): error C2146: syntax error : missing
';' before identifier 'get_scheduler'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1349): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1350): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1352): warning C4183: 'get_scheduler':
missing return type; assumed to be a member function returning 'int'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1360): error C2146: syntax error : missing
';' before identifier '_M_Scheduler'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1360): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1361): error C2146: syntax error : missing
';' before identifier '_M_CancellationToken'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1361): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1366): warning C4520:
'Concurrency::task_options' : multiple default constructors specified
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1203): error C3861: 'get_ambient_scheduler':
identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1205): error C2653: 'cancellation_token' : is
not a class or namespace name
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1205): error C3861: 'none': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1209): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_Scheduler' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1209): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_CancellationToken' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1215): error C3861: 'get_ambient_scheduler':
identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1217): error C2065: '_Token' : undeclared
identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1221): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_Scheduler' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1221): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_CancellationToken' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1227): error C3861: 'get_ambient_scheduler':
identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1229): error C2653: 'cancellation_token' : is
not a class or namespace name
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1229): error C3861: 'none': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1233): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_Scheduler' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1233): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_CancellationToken' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1239): error C3861: 'get_ambient_scheduler':
identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1241): error C2065: '_Token' : undeclared
identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1242): error C2065: '_ContinuationContext' :
undeclared identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1245): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_Scheduler' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1245): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_CancellationToken' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1264): error C2065: '_Scheduler' : undeclared
identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1266): error C2653: 'cancellation_token' : is
not a class or namespace name
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1266): error C3861: 'none': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1270): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_Scheduler' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1270): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_CancellationToken' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1276): error C2065: '_Scheduler' : undeclared
identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1278): error C2653: 'cancellation_token' : is
not a class or namespace name
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1278): error C3861: 'none': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1282): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_Scheduler' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1282): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_CancellationToken' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1294): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_Scheduler' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1294): error C2614:
'Concurrency::task_options' : illegal member initialization:
'_M_CancellationToken' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1302): error C2065: '_M_CancellationToken' :
undeclared identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1302): error C2065: '_Token' : undeclared
identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1327): error C2065: '_M_CancellationToken' :
undeclared identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1351): error C2065: '_M_Scheduler' :
undeclared identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1385): error C2143: syntax error : missing
';' before '<'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1387) : see reference to class template
instantiation 'Concurrency::details::_Task_ptr<_ReturnType>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1385): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1385): error C2238: unexpected token(s)
preceding ';'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1386): error C2146: syntax error : missing
';' before identifier '_Make'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1386): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1386): error C2061: syntax error : identifier
'_CancellationTokenState'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1386): warning C4183: '_Make': missing return
type; assumed to be a member function returning 'int'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1389): error C2653: '_TaskCollection_t' : is
not a class or namespace name
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1389): error C2146: syntax error : missing
';' before identifier '_UnrealizedChore_t'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1389): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1390): error C2039: 'shared_ptr' : is not a
member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1390): error C2143: syntax error : missing
';' before '<'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1390): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1394): error C2516:
'Concurrency::details::_UnrealizedChore_t' : is not a legal base class
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1389) : see declaration of
'Concurrency::details::_UnrealizedChore_t'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1400): error C2146: syntax error : missing
';' before identifier '_M_inliningMode'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1400): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1402): error C2146: syntax error : missing
';' before identifier '_GetTaskImplBase'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1402): error C2433:
'Concurrency::details::_ContinuationTaskHandleBase::_Task_ptr_base' :
'virtual' not permitted on data declarations
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1402): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1402): warning C4183: '_GetTaskImplBase':
missing return type; assumed to be a member function returning 'int'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1402): error C2253:
'Concurrency::details::_ContinuationTaskHandleBase::_GetTaskImplBase' :
pure specifier or abstract override specifier only allowed on virtual
function
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1405): error C2039: '_NoInline' : is not a
member of 'Concurrency::details'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1405): error C2065: '_NoInline' : undeclared
identifier
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1406): error C2614:
'Concurrency::details::_ContinuationTaskHandleBase' : illegal member
initialization: '_M_inliningMode' is not a base or member
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1630): error C2146: syntax error : missing
';' before identifier '_GetTaskImplBase'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1638) : see reference to class template
instantiation
'Concurrency::details::_PPLTaskHandle<_ReturnType,_DerivedTaskHandle,_BaseTaskHandle>'
being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1630): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1631): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1633): warning C4183: '_GetTaskImplBase':
missing return type; assumed to be a member function returning 'int'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1657): error C2061: syntax error : identifier
'_CancellationTokenState'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1679): error C2146: syntax error : missing
';' before identifier '_Wait'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1679): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1680): error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1787): warning C4183: '_Wait': missing return
type; assumed to be a member function returning 'int'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1808): error C2039: 'shared_ptr' : is not a
member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1808): error C2143: syntax error : missing
')' before '<'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1808): error C2143: syntax error : missing
';' before '<'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1808): error C2059: syntax error : '<'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1808): error C2059: syntax error : ')'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1808): error C2238: unexpected token(s)
preceding ';'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1816): error C2039: 'shared_ptr' : is not a
member of 'std'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1816): error C2143: syntax error : missing
')' before '<'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1816): error C2143: syntax error : missing
';' before '<'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1816): error C2059: syntax error : '<'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1816): error C2059: syntax error : ')'
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1817): error C2334: unexpected token(s)
preceding '{'; skipping apparent function body
1>C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\ppltasks.h(1817): fatal error C1003: error count exceeds
100; stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========














Jerry Stuckle

unread,
Jul 27, 2016, 10:16:54 PM7/27/16
to
Weasel response. Show a specific example where it DOES fail.

Jerry Stuckle

unread,
Jul 27, 2016, 10:16:56 PM7/27/16
to
Which is why it's a good idea to use a header guard related to the file
name. But you missed that part - because you don't read so well.

Jerry Stuckle

unread,
Jul 27, 2016, 10:16:56 PM7/27/16
to
Two things.

First of all, that's not the header guard I said.

Second of all, I don't have MSVC 2103 (does anyone? That's not for
another 87 years), but your code compiles just fine with gcc 5.4.0.
Either the code you presented is not what you compiled (maybe you have
another PeopleConcert.h?), or you have a problem with your compiler.

David Brown

unread,
Jul 28, 2016, 4:37:17 AM7/28/16
to
Whoosh! That's the sound Paavo's example makes as it passes completely
over your head.

Since this seems too subtle for you to follow, I'll explain it in small
steps.

The standards (C and C++) make certain classes of identifiers
"reserved". This includes identifiers that start with two underscores,
and identifiers that start with one underscore then a capital letter.
Some of these are reserved for future language changes, others are
reserved for the implementation.

It is good programming practice to take this into account when choosing
your own identifiers.

"Why?", I hear you ask (since you clearly don't understand at the
moment). Avoiding reserved identifiers in your own code means your
identifiers won't crash with reserved identifiers in a different or
future compiler. Similarly, implementations avoid non-reserved
identifiers to avoid crashes with the user code.

So you don't avoid using an identifier like "_PPLCONCRT_H" just because
it might cause trouble /now/, you avoid using it because it might cause
trouble in the future. A future C compiler - such as MSVC 2103 - might
use that as an include guard in one of its own implementation-supplied
header files.

Do you see the point now?

Jerry Stuckle

unread,
Jul 28, 2016, 1:53:25 PM7/28/16
to
Whoosh. You completely missed my response.

No, I didn't miss Paavo's comment. I just pointed out he has a problem
in either his code or his compiler, and that he didn't use the example I
did. Nothing more, nothing less.

But you're too dense to understand that.

Mr Flibble

unread,
Jul 28, 2016, 2:06:55 PM7/28/16
to

Jerry Stuckle

unread,
Jul 28, 2016, 9:09:57 PM7/28/16
to
On 7/28/2016 2:06 PM, Mr Flibble wrote:
>

Nothing of interest.

But he has proven time and time again to be nothing better than a troll
- and a stoopid (but entertaining in his own way) one at that.

woodb...@gmail.com

unread,
Jul 29, 2016, 12:04:26 AM7/29/16
to
On Thursday, July 28, 2016 at 1:06:55 PM UTC-5, Mr Flibble wrote:
>

woodb...@gmail.com

unread,
Jul 29, 2016, 12:35:07 AM7/29/16
to
What compilers? I'd like to check if the developers
of the compilers are planning to support #pragma once.


Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net

red floyd

unread,
Jul 29, 2016, 2:00:41 PM7/29/16
to
On 7/28/2016 9:04 PM, woodb...@gmail.com wrote:
> On Thursday, July 28, 2016 at 1:06:55 PM UTC-5, Mr Flibble wrote:
>>
>
Fuck off.

Good Guy

unread,
Jul 29, 2016, 2:08:31 PM7/29/16
to
On 29/07/2016 05:04, woodb...@gmail.com wrote:
>> <NOTHING>

So Is it all right to swear in the body of the message?

--
With over 350 million devices now running Windows 10, customer
satisfaction is higher than any previous version of windows.

woodb...@gmail.com

unread,
Jul 29, 2016, 4:10:25 PM7/29/16
to
On Friday, July 29, 2016 at 1:08:31 PM UTC-5, Good Guy wrote:
> On 29/07/2016 05:04, woodb...@gmail.com wrote:
> >> <NOTHING>
>
> So Is it all right to swear in the body of the message?
>

Previously I've asked people not to swear in the body of messages.


Brian
Ebenezer Enterprises - "I dare not trust the sweetest frame,
but wholly lean on Yeshua's/Jesus' Name."

http://webEbenezer.net

Good Guy

unread,
Jul 29, 2016, 4:14:24 PM7/29/16
to
On 29/07/2016 21:08, woodb...@gmail.com wrote:

Previously I've asked people not to swear in the body of messages.




I think this is a very good idea.  How people started swearing on these newsgroups is beyond me but I am a Good Guy and people in Windows newsgroups knows me.  They all like reading my posts.


--

If you want to filter all of my posts then please read this article:
<https://support.mozilla.org/en-US/kb/organize-your-messages-using-filters>
In step 7 select "Delete"

Jerry Stuckle

unread,
Jul 29, 2016, 4:17:39 PM7/29/16
to
People swear when they aren't able to make an intelligent post. It
makes them feel like a big person.

To other people they are just small-minded.
0 new messages