Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:45:49+00:00 2026-06-14T11:45:49+00:00

I got the 2 following definition that compile (and work) just fine using XCode

  • 0

I got the 2 following definition that compile (and work) just fine using XCode LLVM-GCC compiler:

#define SAVE_STACK(v)__asm { mov v, ESP }
#define RESTORE_STACK __asm {sub ESP, s }

However when I change the compiler to Apple LLVM I got the following error:

Expected '(' after 'asm'

I replace the {} with () but that doesn’t do the trick, I google on that error couldn’t find anything useful… anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:45:50+00:00Added an answer on June 14, 2026 at 11:45 am

    The __asm {...} style of inline assembly is non-standard and not supported by clang. Instead C++ specifies inline assembly syntax as asm("..."), note the quotes. Also clang uses AT&T assembly syntax so the macros would need to be rewritten to be safe.

    However, some work has been going on to improve support for Microsoft’s non-standard assembly syntax, and Intel style assembly along with it. There’s an option -fenable-experimental-ms-inline-asm that enables what’s been done so far, although I’m not sure when it was introduced or how good the support is in the version of clang you’re using. A simple attempt with the code you show seems to work with a recent version of clang from the SVN trunk.

    #define SAVE_STACK(v)__asm { mov v, ESP }
    #define RESTORE_STACK __asm {sub ESP, s }
    
    int main() {
        int i;
        int s;
        SAVE_STACK(i);
        RESTORE_STACK;
    }
    

    clang++ tmp.cpp -fms-extensions -fenable-experimental-ms-inline-asm -S -o -

            .def     main;
            .scl    2;
            .type   32;
            .endef
            .text
            .globl  main
            .align  16, 0x90
    main:                                   # @main
    # BB#0:                                 # %entry
            pushq   %rax
            #APP
            .intel_syntax
            mov dword ptr [rsp + 4], ESP
            .att_syntax
            #NO_APP
            #APP
            .intel_syntax
            sub ESP, dword ptr [rsp]
            .att_syntax
            #NO_APP
            xorl    %eax, %eax
            popq    %rdx
            ret
    

    And the command clang++ tmp.cpp -fms-extensions -fenable-experimental-ms-inline-asm produces an executable that runs.

    It does still produce warnings like the following though.

    warning: MS-style inline assembly is not supported [-Wmicrosoft]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following block definition, which outputs the block of my/type just fine:
i' m using BlazeDs. In services-config.xml we got following configuration of endPoint. <channel-definition id=any-amf
I got following repeating syntax and I want to keep all <h1> that is
I've got a set of unit tests that used to work very nicely in
I've got the following error: 'DirectActivity' does not contain a definition for 'ddl_jobcode_Id2' and
I have got the following interface definition: public interface ICommandHandler { ILogger Logger {
I've got tables like the following (Django model definition, with a postgres database underlying
I've got a class definition similar to the following: class UUID { public: //
I've got a web site that sporadically throws the following error: Server Error in
I got following code in an XHTML-document and every browser saysit is malformed :(

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.