Error in using ams { } with C++.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jakkem@gmail.com

    Error in using ams { } with C++.

    For example the following gives me error
    "expected `(' before '{' token"
    "expected asm body before '{' token "
    etc.

    int main()
    {
    asm { /* some asm-functions */ }
    }

  • Larry I Smith

    #2
    Re: Error in using ams { } with C++.

    jakkem@gmail.co m wrote:[color=blue]
    > For example the following gives me error
    > "expected `(' before '{' token"
    > "expected asm body before '{' token "
    > etc.
    >
    > int main()
    > {
    > asm { /* some asm-functions */ }
    > }
    >[/color]

    You didn't say which compiler you are using (the rules vary).

    For example, using the GCC compiler suite it's:

    asm ( /* multiple lines of assembler code */ );

    If the -ansi compile switch is specified, then 'asm' is not
    allowed (by ANSI), so you have to use the (GCC specific)
    __asm__ keyword in place of the asm keyword.

    Your compiler may vary...

    Larry

    Comment

    • Larry I Smith

      #3
      Re: Error in using ams { } with C++.

      Larry I Smith wrote:[color=blue]
      > jakkem@gmail.co m wrote:[color=green]
      >> For example the following gives me error
      >> "expected `(' before '{' token"
      >> "expected asm body before '{' token "
      >> etc.
      >>
      >> int main()
      >> {
      >> asm { /* some asm-functions */ }
      >> }
      >>[/color]
      >
      > You didn't say which compiler you are using (the rules vary).
      >
      > For example, using the GCC compiler suite it's:
      >
      > asm ( /* multiple lines of assembler code */ );
      >
      > If the -ansi compile switch is specified, then 'asm' is not
      > allowed (by ANSI), so you have to use the (GCC specific)
      > __asm__ keyword in place of the asm keyword.
      >
      > Your compiler may vary...
      >
      > Larry[/color]

      Microsoft Visual Studio 2005 uses __asm {}, 'asm' is ignored.

      Comment

      • dawone@gmail.com

        #4
        Re: Error in using ams { } with C++.

        I'm using mingw (Dev-C++ IDE)

        Comment

        • Walter Bright

          #5
          Re: Error in using ams { } with C++.


          <jakkem@gmail.c om> wrote in message
          news:1127005858 .739708.141860@ g14g2000cwa.goo glegroups.com.. .[color=blue]
          > For example the following gives me error
          > "expected `(' before '{' token"
          > "expected asm body before '{' token "
          > etc.
          >
          > int main()
          > {
          > asm { /* some asm-functions */ }
          > }[/color]


          Inline assembler: www.digitalmars.com/ctg/ctgInlineAsm.html

          -Walter
          www.digitalmars.com C, C++, D compilers



          Comment

          Working...