Like Tree1Likes
  • 1 Post By _Mike

error in c code...

This is a discussion on error in c code... within the C Programming forums, part of the General Programming Boards category; Error in c code...help? iam inserting assembly language code in c program.. compiler used is DevC++. writing _asm...it is showing ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    6

    error in c code...

    Error in c code...help?
    iam inserting assembly language code in c program..
    compiler used is DevC++.

    writing _asm...it is showing an error....

    i have used _declspec void func(), and it is showing warning....
    (_declspec is microsoft access specifier)

    What should i do to resolve is????

    thnks....

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    well, posting code is usually the way to go, however you are need 2 underscore characters, not one. e.g. __declspec.

    EDIT: Here is the link
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    6
    sir, this is the code with errors mentioned in the comment...




    Code:
    __declspec( naked ) void d()       // warning:"naked attribute diirective ignored"
     {
       _asm       //error:_asm undeclared
              {     //error: "syntax error before token {"
    
                      // assembly code
              }
    }

    reply awaited...

  4. #4
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Same issue that you had with declspec. You need 2 underscores for these directives Plus there is no need for a big font

    e.g.__asm

    Additionally, there are limitations to the naked attribute. Read about it here
    Last edited by AndrewHunter; 08-02-2011 at 01:55 AM.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    Quote Originally Posted by AndrewHunter View Post
    Additionally, there are limitations to the naked attribute. Read about it here
    The biggest limitation in this case would be that the OP is not using a microsoft compiler, so none of the other limitations apply
    @am_1989: I think it might be easier to write your function in a stand alone assembler and link with the object file it produces.
    Last edited by _Mike; 08-02-2011 at 02:17 AM.
    AndrewHunter likes this.

  6. #6
    Registered User
    Join Date
    Aug 2011
    Posts
    6
    ok sir, plz don't use big font.
    u can explain me that without using a big font.. i can easily see it without using microscope....

  7. #7
    Registered User
    Join Date
    Aug 2011
    Posts
    6
    @Mike

    ok sir, thanks for replying..
    I should use a different compiler like MS vc++....

    nd what is this stand alone assembler.....is this TASM, emu8086??

  8. #8
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,649
    Do I perhaps detect someone being sneaky?

  9. #9
    Registered User
    Join Date
    Aug 2011
    Posts
    6
    @rags_to_riches

    thanks sir for the link... :-)

    but, whz being sneaky...pointing to whom??... :-p

  10. #10
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Quote Originally Posted by _Mike View Post
    The biggest limitation in this case would be that the OP is not using a microsoft compiler, so none of the other limitations apply
    Oops, missed that one. I only keyed on his error message that he posted in his first message. Ah, either way the directives are still double underscored.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  11. #11
    Registered User
    Join Date
    Aug 2011
    Posts
    6
    @AndrewHunter
    I know that the directives are double underscored like __declspec...
    so?

  12. #12
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    So....the code you posted only had _asm, note the single underscore. It needs to be __asm, note the double underscore. That is most likely why your compiler is throwing the error with regard to it being an undeclared identifier.
    Last edited by AndrewHunter; 08-04-2011 at 09:52 AM. Reason: spelling
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  13. #13
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by am_1989 View Post
    @AndrewHunter
    I know that the directives are double underscored like __declspec...
    so?
    So? You expect the compiler to GUESS?

    Really...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is there an off-by-one error in this example code?
    By edw211 in forum C Programming
    Replies: 3
    Last Post: 06-14-2011, 07:21 PM
  2. Error in code
    By Markusob in forum C# Programming
    Replies: 6
    Last Post: 05-07-2011, 02:37 PM
  3. Help with VC++ 6.0 (or my code) error
    By theodoreius2000 in forum Game Programming
    Replies: 7
    Last Post: 07-13-2004, 09:48 PM
  4. Need help w/code error
    By LouB in forum C++ Programming
    Replies: 4
    Last Post: 10-12-2003, 06:23 PM
  5. error in code
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 11-25-2001, 06:39 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21