-pedantic and -ansi

Mohsen Pahlevanzadeh mohsen@pahlevanzadeh.org
Thu Jul 12 13:01:00 GMT 2012

Dear all,

My program  in progress... But i predict if i use -pedantic -ansi , may
be my code will be standard...
I don't have any problem, and had following function:
static void * makeFunctionPointer(Method _method, Class
_instance_class,ReturnType _returnType,Parameter1 parameter1 =
0,Parameter2 parameter2 = 0, Parameter3 parameter3 = 0, Parameter4
parameter4 = 0)
void * tempCallback;
typedef decltype(_instance_class) _Class ;
typedef EventHandlerAbstract<_Class, ReturnType, Parameter1, Parameter2, Parameter3, Parameter4>  _callback;
_Class _instance = _Class();
_callback classPointer(&_instance_class, _method);
tempCallback = (static_cast<void*>(&classPointer));
// (*static_cast< _callback* >(tempCallback))(1,2,3,4);
return tempCallback;
now, i get out my func from class body.after test, i'll get out it.
when i use -pedantic -ansi in Makefile, I get the following errors:
Common/eventhandlerabstract.h:102:39: error: ISO C++ forbids declaration of ‘typeof’ with no type [-fpermissive]
Common/eventhandlerabstract.h:102:39: error: typedef ‘typeof’ is initialized (use decltype instead)
Common/eventhandlerabstract.h:103:38: error: ‘_Class’ was not declared in this scope
Common/eventhandlerabstract.h:103:104: error: template argument 1 is invalid
Common/eventhandlerabstract.h:103:116: error: invalid type in declaration before ‘;’ token
Common/eventhandlerabstract.h:104:16: error: expected ‘;’ before ‘_instance’
Common/eventhandlerabstract.h: In instantiation of ‘static void* EventHandlerAbstract<Class, ReturnType, Parameter1, Parameter2, Parameter3, Parameter4>::makeFunctionPointer(EventHandlerAbstract<Class, ReturnType, Parameter1, Parameter2, Parameter3, Parameter4>::Method, Class, ReturnType, Parameter1, Parameter2, Parameter3, Parameter4) [with Class = test; ReturnType = bool; Parameter1 = int; Parameter2 = int; Parameter3 = int; Parameter4 = int; EventHandlerAbstract<Class, ReturnType, Parameter1, Parameter2, Parameter3, Parameter4>::Method = bool (test::*)(int, int, int, int)]’:
main.cpp:31:56:   required from here
Common/eventhandlerabstract.h:105:57: error: expression list treated as compound expression in initializer [-fpermissive]
Common/eventhandlerabstract.h:105:57: warning: left operand of comma operator has no effect [-Wunused-value]
Common/eventhandlerabstract.h:105:57: error: cannot convert ‘EventHandlerAbstract<test, bool, int, int, int, int>::Method {aka bool (test::*)(int, int, int, int)}’ to ‘_callback {aka int}’ in initialization
My program should port to Android and apple, So i we decided to write standard, Do you have any idea with g++?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 316 bytes
Desc: This is a digitally signed message part
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20120712/d2082680/attachment.sig>

More information about the Gcc-help mailing list