amiga.org
     
iconAll times are GMT -6. The time now is 08:10 PM. | Welcome to Forum, please register to access all of our features.

» Amiga.org » Operating System Specific Discussions » Amiga OS » Amiga OS -- Development » ANSI C++ forbids declaration `res' with no type

Amiga OS -- Development This particular forum deals with issues regarding development for all versions of AmigaOS.

Reply
 
Thread Tools Display Modes
Old 04-25-2009, 02:47 PM   #1
EDanaII
Cult Member
Points: 7,148, Level: 55 Points: 7,148, Level: 55 Points: 7,148, Level: 55
Activity: 17% Activity: 17% Activity: 17%
 
EDanaII's Avatar
 
Join Date: Dec 2006
Location: Phoenix, AZ
Posts: 536
Default ANSI C++ forbids declaration `res' with no type

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.
EDanaII is offline   Reply With Quote
Old 04-25-2009, 03:03 PM   #2
Kronos
Resident blue troll
Points: 13,368, Level: 75 Points: 13,368, Level: 75 Points: 13,368, Level: 75
Activity: 2% Activity: 2% Activity: 2%
 
Kronos's Avatar
 
Join Date: Feb 2002
Posts: 3,871
Default Re: ANSI C++ forbids declaration `res' with no type

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
Kronos is offline   Reply With Quote
Old 04-25-2009, 03:08 PM   #3
EDanaII
Cult Member
Points: 7,148, Level: 55 Points: 7,148, Level: 55 Points: 7,148, Level: 55
Activity: 17% Activity: 17% Activity: 17%
 
EDanaII's Avatar
 
Join Date: Dec 2006
Location: Phoenix, AZ
Posts: 536
Default Re: ANSI C++ forbids declaration `res' with no type

Except I get the exact same results when I compile using gcc, Kronos.

The code looks like this:
Code:
#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.
EDanaII is offline   Reply With Quote
Old 04-25-2009, 03:17 PM   #4
EDanaII
Cult Member
Points: 7,148, Level: 55 Points: 7,148, Level: 55 Points: 7,148, Level: 55
Activity: 17% Activity: 17% Activity: 17%
 
EDanaII's Avatar
 
Join Date: Dec 2006
Location: Phoenix, AZ
Posts: 536
Default Re: ANSI C++ forbids declaration `res' with no type

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.
EDanaII is offline   Reply With Quote
Old 04-25-2009, 03:17 PM   #5
Kronos
Resident blue troll
Points: 13,368, Level: 75 Points: 13,368, Level: 75 Points: 13,368, Level: 75
Activity: 2% Activity: 2% Activity: 2%
 
Kronos's Avatar
 
Join Date: Feb 2002
Posts: 3,871
Default Re: ANSI C++ forbids declaration `res' with no type

I would have needed the actual header file (you know the line where "res" is defined (without a type).

But... ;-)

Since you allready include <clib/muimaster_protos.h> you might get away with commenting <inline/muimaster.h> 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
Kronos is offline   Reply With Quote
Old 04-25-2009, 03:25 PM   #6
EDanaII
Cult Member
Points: 7,148, Level: 55 Points: 7,148, Level: 55 Points: 7,148, Level: 55
Activity: 17% Activity: 17% Activity: 17%
 
EDanaII's Avatar
 
Join Date: Dec 2006
Location: Phoenix, AZ
Posts: 536
Default Re: ANSI C++ forbids declaration `res' with no type

I get an undefined reference to main when I comment it out in both compilers.

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

Ed.
EDanaII is offline   Reply With Quote
Old 04-25-2009, 03:32 PM   #7
Kronos
Resident blue troll
Points: 13,368, Level: 75 Points: 13,368, Level: 75 Points: 13,368, Level: 75
Activity: 2% Activity: 2% Activity: 2%
 
Kronos's Avatar
 
Join Date: Feb 2002
Posts: 3,871
Default Re: ANSI C++ forbids declaration `res' with no type

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 <inline/...> when compiled with GNU and <clib/..> 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
Kronos is offline   Reply With Quote
Old 04-25-2009, 03:46 PM   #8
EDanaII
Cult Member
Points: 7,148, Level: 55 Points: 7,148, Level: 55 Points: 7,148, Level: 55
Activity: 17% Activity: 17% Activity: 17%
 
EDanaII's Avatar
 
Join Date: Dec 2006
Location: Phoenix, AZ
Posts: 536
Default Re: ANSI C++ forbids declaration `res' with no type

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.
EDanaII is offline   Reply With Quote
Old 04-25-2009, 05:29 PM   #9
EDanaII
Cult Member
Points: 7,148, Level: 55 Points: 7,148, Level: 55 Points: 7,148, Level: 55
Activity: 17% Activity: 17% Activity: 17%
 
EDanaII's Avatar
 
Join Date: Dec 2006
Location: Phoenix, AZ
Posts: 536
Default Re: ANSI C++ forbids declaration `res' with no type

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.
EDanaII is offline   Reply With Quote
Old 04-28-2009, 09:36 AM   #10
EDanaII
Cult Member
Points: 7,148, Level: 55 Points: 7,148, Level: 55 Points: 7,148, Level: 55
Activity: 17% Activity: 17% Activity: 17%
 
EDanaII's Avatar
 
Join Date: Dec 2006
Location: Phoenix, AZ
Posts: 536
Default Re: ANSI C++ forbids declaration `res' with no type

[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.
EDanaII is offline   Reply With Quote
Old 04-28-2009, 11:03 AM   #11
CSixx
Technoid
Points: 5,719, Level: 48 Points: 5,719, Level: 48 Points: 5,719, Level: 48
Activity: 4% Activity: 4% Activity: 4%
 
Join Date: Jan 2006
Location: Tacoma, Wa
Posts: 312
Default Re: ANSI C++ forbids declaration `res' with no type

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();


CSixx is offline   Reply With Quote
Old 04-28-2009, 11:31 AM   #12
x303
Cult Member
Points: 11,054, Level: 69 Points: 11,054, Level: 69 Points: 11,054, Level: 69
Activity: 2% Activity: 2% Activity: 2%
 
x303's Avatar
 
Join Date: Feb 2002
Location: Amsterdam
Posts: 622
Default Re: ANSI C++ forbids declaration `res' with no type

Maybe you wanna try it with -fno-strict-prototype or kick the -ansi, -traditional and/or -pedantic option(s).

x303 :-D :-D :-D
x303 is offline   Reply With Quote
Old 04-28-2009, 01:03 PM   #13
Kronos
Resident blue troll
Points: 13,368, Level: 75 Points: 13,368, Level: 75 Points: 13,368, Level: 75
Activity: 2% Activity: 2% Activity: 2%
 
Kronos's Avatar
 
Join Date: Feb 2002
Posts: 3,871
Default Re: ANSI C++ forbids declaration `res' with no type

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
Kronos is offline   Reply With Quote
Old 04-28-2009, 07:53 PM   #14
EDanaII
Cult Member
Points: 7,148, Level: 55 Points: 7,148, Level: 55 Points: 7,148, Level: 55
Activity: 17% Activity: 17% Activity: 17%
 
EDanaII's Avatar
 
Join Date: Dec 2006
Location: Phoenix, AZ
Posts: 536
Default Re: ANSI C++ forbids declaration `res' with no type

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:
while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
Ed.
EDanaII is offline   Reply With Quote
Old 04-28-2009, 08:08 PM   #15
Fab12
Beginner
Points: 2,055, Level: 27 Points: 2,055, Level: 27 Points: 2,055, Level: 27
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2006
Posts: 37
Default Re: ANSI C++ forbids declaration `res' with no type

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.
Fab12 is offline   Reply With Quote
Reply

Bookmarks

Tags
c++ , `res , type , forbids , declaration , ansi

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ansi capable telnet application for OS3.x? AmiKit Amiga Software Issues and Discussion 5 04-09-2009 12:37 PM
How do I check size/date of a file in ANSI C? ChaosLord Amiga OS -- Development 10 02-16-2006 04:17 AM
Karlos' weekly GNU/ANSI C++ on amiga bash :-) Karlos Amiga OS -- Development 5 04-08-2004 04:43 PM
More GNU C++ (ANSI C++ mode) oddness Karlos Amiga OS -- Development 14 03-26-2004 11:02 AM
Longs, ints and printf (ansi-C) elendil Amiga OS -- Development 7 03-15-2004 08:56 AM