[aspectc-user] Can't compile with a function that takes an argument of string object

Herry Leonard herryleo at singnet.com.sg
Thu Jul 3 05:26:35 CEST 2003


Hi all,

I create a simple function with a string object as its argument. The parsing is working 
fine, but during compilation with g++, I get bunch of errors.

Btw, I am using aspectc++ version 0.7 (01.07.2003) and g++ version 2.96 in Red Hat 
Linux 7.2 box.

I attached the sample program below:

[main.cpp]

#include <string>
#include <stdio.h>

class MyClass
{
    public:
        void MethodA(const string&);
};

void MyClass::MethodA(const string& s1)
{
    printf("I'm in MethodA\n");
}

int main()
{
    MyClass myClass;
    myClass.MethodA("test");
    return 0;
}


[Action.ah]

#include <stdio.h>

aspect Action {
  advice execution("% MyClass::%(...)") || execution("% MyClass(...)") : void before()  {
    printf("before execution\n");
  }
  advice execution("% MyClass::%(...)") || execution("% MyClass(...)") : void after()  {
    printf("after execution\n");
  }
};


During g++ compilation of aspectc++-generated codes, I got there errors:
g++  -o action main.cpp ac_gen.cpp
main.cpp:14: syntax error before `%'
main.cpp:14: nondigits in number and not hexadecimal
main.cpp:14: nondigits in number and not hexadecimal
main.cpp:14: nondigits in number and not hexadecimal
main.cpp:14: missing white space after number `12basi'
main.cpp:20: syntax error before `%'
main.cpp:20: nondigits in number and not hexadecimal
main.cpp:20: nondigits in number and not hexadecimal
main.cpp:20: nondigits in number and not hexadecimal
main.cpp:20: missing white space after number `12basi'
main.cpp:30: wrong number of template arguments (0, should be 3)
/usr/include/g++-3/std/bastring.h:67: provided for `template <charT,
traits, Allocator> class basic_string'
main.cpp:31: ISO C++ forbids declaration of `arg0' with no type
main.cpp:31: prototype for `void MyClass::MethodA (const int &)' does
not match any in class `MyClass'
main.cpp:9: candidate is: void MyClass::MethodA (const string &)
main.cpp: In method `void MyClass::MethodA (const int &)':
main.cpp:32: `a0_before_Action_exec_MyClassMethodA_FN7MyClassEvRKN15'
undeclared (first use this function)
main.cpp:32: (Each undeclared identifier is reported only once for each
function it appears in.)
main.cpp:32: nondigits in number and not hexadecimal
main.cpp:32: nondigits in number and not hexadecimal
main.cpp:32: nondigits in number and not hexadecimal
main.cpp:32: missing white space after number `12basi'
main.cpp:32: wrong number of template arguments (0, should be 3)
/usr/include/g++-3/std/bastring.h:67: provided for `template <charT,
traits, Allocator> class basic_string'
main.cpp:32: parse error before `12basi'
main.cpp:33: no matching function for call to `MyClass::__old_MethodA
(const int &)'
main.cpp:27: candidates are: void MyClass::__old_MethodA (const string
&)
main.cpp:34: `a1_after_Action_exec_MyClassMethodA_FN7MyClassEvRKN15'
undeclared (first use this function)
main.cpp:34: nondigits in number and not hexadecimal
main.cpp:34: nondigits in number and not hexadecimal
main.cpp:34: nondigits in number and not hexadecimal
main.cpp:34: missing white space after number `12basi'
main.cpp:34: wrong number of template arguments (0, should be 3)
/usr/include/g++-3/std/bastring.h:67: provided for `template <charT,
traits, Allocator> class basic_string'
main.cpp:34: parse error before `12basi'
make: *** [action] Error 1


Is there anything wrong in my codes above? Could we use string as the argument for a 
function? Btw, if I use string object inside function only, it works fine.

Thanks.

Regards,
Herry Leonard




More information about the aspectc-user mailing list