From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26390 invoked by alias); 13 Dec 2013 12:04:22 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 26378 invoked by uid 89); 13 Dec 2013 12:04:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qe0-f50.google.com Received: from mail-qe0-f50.google.com (HELO mail-qe0-f50.google.com) (209.85.128.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 13 Dec 2013 12:04:21 +0000 Received: by mail-qe0-f50.google.com with SMTP id 1so1506917qec.9 for ; Fri, 13 Dec 2013 04:04:19 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.32.131 with SMTP id c3mr3924718qad.3.1386936259189; Fri, 13 Dec 2013 04:04:19 -0800 (PST) Received: by 10.140.47.7 with HTTP; Fri, 13 Dec 2013 04:04:19 -0800 (PST) Date: Fri, 13 Dec 2013 12:04:00 -0000 Message-ID: Subject: C++ name mangling From: Philip Herron To: GCC Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00099.txt.bz2 Hey I never really looked into this much before but kind of just out of curiosity where is it implemented. For example: C++ code: int test (int)... will generate the gimple: int test(int) (int x) { int D.2281; D.2281 = x + 1; return D.2281; } But then the aseembler name is: _Z4testi: I know you can do SET_DECL_ASSEMBLER_NAME on an fndecl. But not sure how the mangling is done for C++ is there a convention to the c++ standard or is it compiler specific i imagine it must be some standard. And where is it implemented in Rust you can do: #[link_args = "-lreadline"] extern { fn readline (p: *std::libc::c_char) -> * std::libc::c_char; } I would like to be able to do something like: extern "c++" { } So then any rust program can call into c++ wrappers maybe? Maybe leaving out templates and classes. Maybe i can do something like SET_DECL_ASSEMBLER_NAME (cpp_mangle ("test")) --Phil --Phil