Thread: C++ gnu gcc compiler error

  1. #1
    Registered User
    Join Date
    Jul 2015
    Posts
    17

    C++ gnu gcc compiler error

    Greetings,

    I am currently in the process of switching compilers.

    From microtech to GNU GCC/G++ coldfire..

    I keep receiving the following error and can not find a simple solution:

    warning: ANSI C++ forbids declaration `interrupt' with no type

    I know the line that it is failing on:

    friend interrupt void IrqCtmMCSM2(void);

    Could someone offer suggestions please?

    Thanks for your time.

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    It probably says that it doesn't recognize "interrupt" as a keyword, but as a simple identifier. GCC has a special instruction "__attribute__" which can be used to do something similar, like this:

    Code:
    friend __attribute__((interrupt)) void IrqCtmMCSM2(void);
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    That was a great solution!! thank you!
    However, it presented another error.

    `IrqCtmMCSM2' undeclared (first use this function)

    The prototype is in the .hpp file and it is included in the .cpp.

    I do not understand why it thinks that it is not declared.

    Would you mind helping with this as well?
    Last edited by Jscott; 07-08-2015 at 12:11 PM.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Does that happen inside the same file or in a separate file? Are you sure you have included the appropriate headers?
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    The header file is included and the first use is in the .cpp file.

  6. #6
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    however, in my header file i am using...

    #ifdef _GNUC_
    friend __attribute__((interrupt)) void IrqCtmMCSM2(void);
    friend __attribute__((interrupt)) void IrqCtmDASM3(void);
    friend __attribute__((interrupt)) void IrqCtmDASM4(void);
    friend __attribute__((interrupt)) void IrqCtmPWSM5(void);
    friend __attribute__((interrupt)) void IrqCtmPWSM6(void);
    friend __attribute__((interrupt)) void IrqCtmPWSM7(void);
    friend __attribute__((interrupt)) void IrqCtmPWSM8(void);
    friend __attribute__((interrupt)) void IrqCtmDASM9(void);
    friend __attribute__((interrupt)) void IrqCtmDASM10(void);
    friend __attribute__((interrupt)) void IrqCtmMCSM11(void);
    friend __attribute__((interrupt)) void IrqCtmFCSM12(void);
    #else
    friend interrupt void IrqCtmMCSM2(void);
    friend interrupt void IrqCtmDASM3(void);
    friend interrupt void IrqCtmDASM4(void);
    friend interrupt void IrqCtmPWSM5(void);
    friend interrupt void IrqCtmPWSM6(void);
    friend interrupt void IrqCtmPWSM7(void);
    friend interrupt void IrqCtmPWSM8(void);
    friend interrupt void IrqCtmDASM9(void);
    friend interrupt void IrqCtmDASM10(void);
    friend interrupt void IrqCtmMCSM11(void);
    friend interrupt void IrqCtmFCSM12(void);
    #endif

    I do not believe its working properly

  7. #7
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Yeah, you need two underscores before and after GNUC: __GNUC__
    Devoted my life to programming...

  8. #8
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    That works!

    Im new to this forum, is there a way to rep??

    Thanks for your help!

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You can "Like" GReaper's post(s).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    Welp I am back in regards to the question/solution that I asked yesterday,

    Okay, heres what is happening...

    The following line of code worked perfectly for declaring the interrupt function in the header file.
    Code:
    friend__attribute__((interrupt)) voidIrqCtmMCSM2(void);
    However, I tried to do the same thing in the code file..
    Code:
    __attribute__((interrupt)) void IrqCtmMCSM2 (void) {}
    This keeps on giving me the following error:

    warning: `interrupt' attribute directive ignored

    I have searched online and there where 'old' posts about the GNU compiler not supporting this attribute.

    Does anyone have any experience with the GNU compiler from an embedded point of view?

    Thanks for your time guys! I really appreciate it!

    -J

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 12-13-2010, 10:02 PM
  2. GCC compiler giving syntax error before 'double' error
    By dragonmint in forum Linux Programming
    Replies: 4
    Last Post: 06-02-2007, 05:38 PM
  3. Compiler error error C2065: '_beginthreadex; : undeclared identifier
    By Roaring_Tiger in forum Windows Programming
    Replies: 3
    Last Post: 04-29-2003, 01:54 AM
  4. Compiler error or human error?
    By skyruler54 in forum C++ Programming
    Replies: 6
    Last Post: 09-06-2002, 02:27 PM
  5. fatal error C1001: INTERNAL COMPILER ERROR
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-21-2002, 12:07 PM

Tags for this Thread