Welcome, Guest. Please login or register.

Author Topic: ANSI C++ forbids declaration `res' with no type  (Read 3758 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
ANSI C++ forbids declaration `res' with no type
« on: April 25, 2009, 09:47:28 PM »
Once again, I'd ordinarily post this on UtilityBase but they haven't gotten rid of their "bad juju" at the moment... :(

Trying to compile a MUI example, I'm getting lots of errors. Instead of compiling this in AmiDevCpp like I normally do, I tried compiling it in G++ directly in UAE using this command: g++ -noixemul -I InclMUID: -I InclOS39: -o MUITest MUITest.cpp

This is the results:
Quote
InclMUID:inline/muimaster.h: In function `void MUI_FreeAslRequest(void *)':
InclMUID:inline/muimaster.h:133: ANSI C++ forbids declaration `res' with no type


Not sure how to fix this. Clues appreciated.

Ed.
Ed.
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: ANSI C++ forbids declaration `res' with no type
« Reply #1 on: April 25, 2009, 10:03:56 PM »
Well, it would have helped had you posted the piece of code in question instead of just the error-message (I only have the MorphOS-Version of the MUI-includes at hand and I'm quite sure the inlines are somewhat different here).

But ....

MUI and C++ don't allways mix that well, so just calling gcc instead of g++ might allready make a differnce.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: ANSI C++ forbids declaration `res' with no type
« Reply #2 on: April 25, 2009, 10:08:57 PM »
Except I get the exact same results when I compile using gcc, Kronos. :)

The code looks like this:
Code: [Select]
#ifndef PROTO_MUIMASTER_H
#define PROTO_MUIMASTER_H

#ifndef LIBRARIES_MUI_H
#include <libraries/mui.h>
#endif /* !LIBRARIES_MUI_H */

#include <clib/muimaster_protos.h>

#ifdef __GNUC__
#include <inline/muimaster.h>
#endif /* __GNUC__ */

#ifndef __NOLIBBASE__
extern struct Library *
#ifdef __CONSTLIBBASEDECL__
__CONSTLIBBASEDECL__
#endif /* __CONSTLIBBASEDECL__ */
MUIMasterBase;
#endif /* !__NOLIBBASE__ */

#endif /* !PROTO_MUIMASTER_H */


Someone wrote on UtilityBase that they fixed it using fd2pragma, but didn't demonstrate how. I got no clues on how to use fd2pragma, unfortunately.

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: ANSI C++ forbids declaration `res' with no type
« Reply #3 on: April 25, 2009, 10:17:22 PM »
These are the errors I get, BTW, when I compile it in AmiDevCpp:
Quote
11 W:\Projects\Amiga\MUI\MuiTest.cpp In file included from MuiTest.cpp
 P:\Windows\AmiDevCpp\usr\local\amiga\m68k-amigaos\sys-include\inline\muimaster.h In function `Object * MUI_NewObjectA(char *, TagItem *)':
10 P:\Windows\AmiDevCpp\usr\local\amiga\m68k-amigaos\sys-include\inline\muimaster.h parse error before `__asm'
10 P:\Windows\AmiDevCpp\usr\local\amiga\m68k-amigaos\sys-include\inline\muimaster.h parse error before `*'
10 P:\Windows\AmiDevCpp\usr\local\amiga\m68k-amigaos\sys-include\inline\muimaster.h parse error before `*'


Ed.
Ed.
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: ANSI C++ forbids declaration `res' with no type
« Reply #4 on: April 25, 2009, 10:17:41 PM »
I would have needed the actual header file (you know the line where "res" is defined (without a type).

But...  ;-)

Since you allready include you might get away with commenting out.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: ANSI C++ forbids declaration `res' with no type
« Reply #5 on: April 25, 2009, 10:25:43 PM »
I get an undefined reference to main when I comment it out in both compilers.

The code in question looks like this:
Code: [Select]
static __inline Object * MUI_NewObjectA(char * a0arg, struct TagItem * tags)
{
  return ((Object * (*)(char * __asm(&quot;a0&quot;), struct TagItem * __asm(&quot;a1&quot;), struct Library * __asm(&quot;a6&quot;)))
  (((char *) MUIMASTER_BASE_NAME) - 30))(a0arg, tags, MUIMASTER_BASE_NAME);

}

Ed.
Ed.
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: ANSI C++ forbids declaration `res' with no type
« Reply #6 on: April 25, 2009, 10:32:19 PM »
main() certainly is NOT those headers, and if your missing it, something is rotten with your source-code.

I've just located a copy of the MUI3.8SDK on my hard-disk (sometimes being a messy pays ......), and the examples seem to only include when compiled with GNU and otherwise. Could you try some of those ?
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: ANSI C++ forbids declaration `res' with no type
« Reply #7 on: April 25, 2009, 10:46:56 PM »
Sure, if you got examples that do compile, I'd welcome the chance to try them. I could at least know then the problem was definitely me, although I'm fairly convinced of that anyway. ;)

Now, taking your point seriously about the missing main, I switched my source code examples and compiled a different example after commenting out the inline/muimaster.h. I'm still getting the error in question when compiling against gcc, but they disappear when compiling against AmiDevCpp. I still have errors in both, but at least there's some clues here. Perhaps a difference in include files?

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: ANSI C++ forbids declaration `res' with no type
« Reply #8 on: April 26, 2009, 12:29:29 AM »
Pursuing things further in AmiDevCpp, following Kronos' advice and commenting out that inline/muimaster.h reduces my errors to just these:
Quote
94 W:\Projects\Amiga\MUI\MuiTest.cpp implicit declaration of function `int DoMethod(...)'
96 W:\Projects\Amiga\MUI\MuiTest.cpp implicit declaration of function `int set(...)'
113 W:\Projects\Amiga\MUI\MuiTest.cpp ANSI C++ forbids implicit conversion from `void *' in argument passing


I tried linking it to Amiga.lib, but that didn't work. I'm not sure if I need to declare those methods as externs or just pic the right library. Once again, if anyone's got some clues, I'd love to hear them.

Ed.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: ANSI C++ forbids declaration `res' with no type
« Reply #9 on: April 28, 2009, 04:36:05 PM »
[bump]

OK, so no one can tell me how to get rid of this implicit declaration error? I assume it's some compiler or linker setting...

Ed.
Ed.
 

Offline CSixx

  • Sr. Member
  • ****
  • Join Date: Jan 2006
  • Posts: 315
    • Show only replies by CSixx
Re: ANSI C++ forbids declaration `res' with no type
« Reply #10 on: April 28, 2009, 06:03:51 PM »
Assumptions aren't going to help you.
I get the feeling you are trying to jump right into the meat of development without understanding the basics.

Do you have an MuiTest.h file where you have declared the methods that it is complaining about?

Or have you setup your declarations at the top of your .cpp files instead?

such as:

void DoMethod();


 

Offline x303

Re: ANSI C++ forbids declaration `res' with no type
« Reply #11 on: April 28, 2009, 06:31:35 PM »
Maybe you wanna try it with -fno-strict-prototype or kick the -ansi, -traditional and/or -pedantic option(s).

[color=ff0000]x303[/color] :-D  :-D  :-D
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: ANSI C++ forbids declaration `res' with no type
« Reply #12 on: April 28, 2009, 08:03:32 PM »
DoMethod() is in amiga.lib, so you have to include the stubs for that. set ? I'm not 100% sure, but probraly it's just some macro falling back to SetAttrs() in intuition.

If you don't know how and where to include those stubs, you are obviously trying step 15 before step 8.

You may still go back to downloading the MUI-SDK (it's on the Aminet) adn try one of those examples.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: ANSI C++ forbids declaration `res' with no type
« Reply #13 on: April 29, 2009, 02:53:20 AM »
Ummm... the problem is, Kronos, I *AM* using the MUI SDK examples. I am assuming that this is a difference in compilers and/or environments as I am now attempting this is AmiDevCpp. I've made better progress there than using GCC on UAE.

And, c'mon guys, gimmee a break. :-) It's not like I can go out and buy a book on this stuff. Believe me, I'd love to, but all the different (and meager) sources I can find don't clue me in on a whole lot, otherwise I wouldn't be buggin' you here.

If you've got something out there that explains all the proper steps in the proper order, by all means, clue me in...

Now, having said all that, the only library I can find that has a reference to the DoMethod procedure is the clib/alib_protos.h which looks right but for all I know isn't.

It certainly changes my errors to this:
Quote
99 W:\Projects\Amiga\MUI\MuiTest.cpp ANSI C++ forbids implicit conversion from `void *' in argument passing


With the code in question looking like this:
Code: [Select]
while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)

Ed.
Ed.
 

Offline Fab12

  • Newbie
  • *
  • Join Date: Sep 2006
  • Posts: 37
    • Show only replies by Fab12
Re: ANSI C++ forbids declaration `res' with no type
« Reply #14 on: April 29, 2009, 03:08:07 AM »
Easy one. C++ is much more strict about types and doesn't allow implicit casting to (void *).
As DoMethod() expect "Object *" as object, either define your MUI objects as Object * instead of APTR, or cast them to (Object*) in DoMethod() call.

Having compiled mui classes for OWB-MorphOS in C++, I can safely say casts are the main difference to C. Can't remember any other issue so far.