error : $S1 : modifiers not allowed ?!



Hello,

the following source code is not correct, but i cannot understand the error
message:

foo.cpp(20) : error C2270: '$S1' : modifiers not allowed on nonmember
functions
foo.cpp(20) : error C4430: missing type specifier - int assumed. Note: C++
does not support default-int

what does this $S1 mean?

Here is the sample:

======= foo.cpp ===========
class Foo;

class Bar
{
public:
operator Foo() const;
};

struct Foo;

typedef struct Foo
{
} Foo;


Bar::operator Foo() const
{
return Foo();
}
============================

cl -W4 -nologo foo.cpp
foo.cpp
foo.cpp(12) : warning C4099: 'Foo' : type name first seen using 'class' now
seen using 'struct'
foo.cpp(2) : see declaration of 'Foo'
foo.cpp(15) : warning C4099: 'Foo' : type name first seen using 'class' now
seen using 'struct'
foo.cpp(2) : see declaration of 'Foo'
foo.cpp(19) : error C2738: 'operator Foo' : is ambiguous or is not a member
of 'Bar'
foo.cpp(7) : see declaration of 'Bar'
foo.cpp(20) : error C2270: '$S1' : modifiers not allowed on nonmember
functions
foo.cpp(20) : error C4430: missing type specifier - int assumed. Note: C++
does not support default-int
foo.cpp(21) : error C2440: 'return' : cannot convert from 'Foo' to 'int'
No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called
foo.cpp(22) : error C2617: '$S1' : inconsistent return statement
foo.cpp(19) : see declaration of '$S1'



.



Relevant Pages

  • Re: Question about multiple files
    ... No. extern just means: The actual definition is somewhere else. ... the compiler can differentiate between declaration and definition just ... > declaration it finds and in this way can I write code expecting it to be ... When the compiler reaches the line foo(); ...
    (alt.comp.lang.learn.c-cpp)
  • RE: RFC on first perl script
    ... print $foo; ... Global symbol "$foo" requires explicit package name at - line 4 ... my EXPR: ATTRS ... The "our" declaration has no semantic ...
    (perl.beginners)
  • Re: Weird gcc behaviour with function pointer types
    ... void (struct foo *); ... This looks like a bug in gcc to me -- what do people ... If there is no outer declaration of struct foo visible to both ... Adding the typedef provides a common declaration of struct foo that is ...
    (comp.lang.python)
  • Re: error : $S1 : modifiers not allowed ?!
    ... does not support default-int ... operator Foo() const; ... You can't now try to declare a struct of the same name. ... foo.cpp: see declaration of 'Foo' ...
    (microsoft.public.vc.language)
  • Re: Newbie static class member question [C++]
    ... >and allows subsequent declarations to refer to Foo in certain contexts ... there is a name 'i' which designates an int ... In some contexts a declaration is also a definition. ...
    (alt.comp.lang.learn.c-cpp)