From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70173 invoked by alias); 30 Mar 2017 14:03:15 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 70138 invoked by uid 89); 30 Mar 2017 14:03:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=Andre, andre, discovering, hunger X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Mar 2017 14:03:11 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AE646AB1D; Thu, 30 Mar 2017 14:03:10 +0000 (UTC) Date: Thu, 30 Mar 2017 14:03:00 -0000 From: Martin Jambor To: Andre Groenewald Cc: gcc@gcc.gnu.org Subject: Re: Fwd: GCC front end and GCC internals Message-ID: <20170330140310.d3b4rigu23qz7xyn@virgil.suse.cz> Mail-Followup-To: Andre Groenewald , gcc@gcc.gnu.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.2 (2016-07-01) X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00185.txt.bz2 Hello, I am not sure if I can help you but... On Thu, Mar 30, 2017 at 08:05:07AM +0200, Andre Groenewald wrote: > I am discovering the awesome world of GCC internals. I managed to > develop a basic front end. It can call internal and external functions > and link with standard libraries. All is good. > > The hunger for more does not end. I want to call c++ libraries and > interact with c++ objects. > > My starting point was to call a test c++ method. I created a test c++ > class with a test method/function. It was compiled into a library. The > library was tested with c++ program and it worked. I manage to call it > from my front end, but the parameter I passed was messed up. It was > some random value every time I called the method. > > I disassembled my program and the test c++ program, then compared the > two. I found that it uses a different register as in the case when > calling a standard c style function. > > It seems that methods are different in the calling convention than > normal functions, which is fine. All that I need to do is set correct > tree property and every will work, right? The question is what tree > property should I set, which macro should I use to set that property? > ...calling conventions (and anything defied in an Application Binary Interface) is of course dependant on the architecture and operating system you are compiling for, so you need to tell us that. Having said that, the only target that I know about that uses different argument passing for methods and for functions is i686-mingw32 (MS Windows). If that is your case, make sure that the type of the function being called is METHOD_TYPE and not FUNCTION_TYPE (but that is actually good for consistency on any platform). Except for static methods, those are functions in gcc internals. If this does not help, you'll need to provide much more details about your whole setup. Martin