[C++-sig] init< LPCTSTR > error if used in static member of same class

AdrianB adrian.baetu at plato-ag.com
Wed Feb 23 12:27:25 CET 2011

Anny Idea why following situation failes to compile?

class A
	A( LPCTSTR szParam ){};

class B: public A
	B( LPCTSTR szParam ) A(szParam){};

	static void includePyModuleDefinition();

void B::includePyModuleDefinition()
	class_<B>("MyB", init< LPCTSTR >() );

Compiler result is:
error C2275: 'LPCTSTR' : illegal use of this type as an expression
  c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(391) : 
                                             see declaration of 'LPCTSTR'
error C2059: syntax error : ')'

The eonly way to solve this issue by now are:
- use no_init => not an option for me because I need the parameter
- move the static member function out of the class B => unhappy because this
would be a breach of my codeing std. for this module 
- remove the class inheritance for B to 'public A'

The problem arises only if following three facts come togather:
1) inheritance  from a base class
2) the includePyModuleDefinition() is a static member of the exposed class 
3) the init has to tale at least one param


More information about the Cplusplus-sig mailing list