From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,23ca868289d9f0c,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!b28g2000cwb.googlegroups.com!not-for-mail From: "cl1" Newsgroups: comp.lang.ada Subject: generic package with procedure paramter gives "not subtype conformant with declaration" Date: 30 Sep 2006 14:20:01 -0700 Organization: http://groups.google.com Message-ID: <1159651201.121690.130430@b28g2000cwb.googlegroups.com> NNTP-Posting-Host: 66.160.210.65 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1159651205 26579 127.0.0.1 (30 Sep 2006 21:20:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 30 Sep 2006 21:20:05 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: b28g2000cwb.googlegroups.com; posting-host=66.160.210.65; posting-account=MCxsfw0AAABxs2rB6FOIOk-6XLUrvbBM Xref: g2news2.google.com comp.lang.ada:6814 Date: 2006-09-30T14:20:01-07:00 List-Id: I don't understand why i can't pass Av_Param to the generic package (in test_call_avcall_register_type.adb) and have its 'Access attribute used in Concat (the offending code in avcall-register_type.adb)? i'm getting the following error: $ gnatmake -gnatc ./Ada_Source/test_avcall_register_type.adb gcc -c -I./Ada_Source/ -gnatc -I- ./Ada_Source/test_avcall_register_type.adb gcc -c -I./Ada_Source/ -gnatc -I- ./Ada_Source/avcall.adb gcc -c -I./Ada_Source/ -gnatc -I- ./Ada_Source/avcall-register_type.adb avcall-register_type.adb:13:34: not subtype conformant with declaration at avcall.ads:37 avcall-register_type.adb:13:34: formal subprograms not allowed gnatmake: "./Ada_Source/avcall-register_type.adb" compilation error on this code: with System; use System; package avcall is -- ---------------------------------------------------------------------------- -- This exeption is thrown when you try to add more than Max_Args to the -- Var_Args type Max_Arg_Limit_Surpassed : exception; ---------------------------------------------------------------------------- -- The maximum number of arguments that can be used by avcall Max_Args : constant := 50; ---------------------------------------------------------------------------- -- this is the number of arguments in the Var_Args list subtype Arg_Count is Natural range 0..Max_Args; ---------------------------------------------------------------------------- -- This is the range used by the Var_Args list subtype Arg_Range is Natural range 1..Max_Args; ---------------------------------------------------------------------------- -- this represents an argument held in the Arg_List type Argument is tagged record ------------------------------------------------------------------------ -- This holds the correct av_ c function to call. Av_Param : access procedure(Av_List : System.Address; Value : System.Address); ------------------------------------------------------------------------ -- This holds the address of the value. This is assigned by the child -- type of this type in the Register_Type package during the -- Initialize procedure call of the child type. Value_Address : System.Address; ------------------------------------------------------------------------ end record; ---------------------------------------------------------------------------- -- This type is used by the Var_Args type to hold all of the arguments. type Arg_List is array(Arg_Range range <>) of Argument; ---------------------------------------------------------------------------- -- This is the Var_Args type. This is used to hold all of the arguments to -- the c function (the ... and all the arguments before that). -- The Start_Var_Args, "&", and Prepend methods and functions are used to -- add arguments to Var_Args. type Var_Args is record ------------------------------------------------------------------------ -- this is a pointer to the c data type that makes this work. -- Av_List_Malloc and Av_List_Free (defined in the body) are used to -- obtain the reference and free it respectivly Av_List : System.Address; ------------------------------------------------------------------------ -- This is the number of arguments in the Arg_List Count : access Arg_Count; ------------------------------------------------------------------------ -- This is what holds all of the arguments. List : access Arg_List := new Arg_List(Arg_Range'Range); ------------------------------------------------------------------------ end record; ---------------------------------------------------------------------------- -- end avcall; with System.Address_To_Access_Conversions; with System; use System; -------------------------------------------------------------------------------- generic type Any_Type is private; with procedure Av_Param_Instance(AList : System.Address; Value : System.Address); package avcall.register_type is ---------------------------------------------------------------------------- package Any_Type_Conversion is new System.Address_To_Access_Conversions(Any_Type); ---------------------------------------------------------------------------- type Argument_Instance is new Argument with record Instance_Value : Any_Type_Conversion.Object_Pointer; end record; ---------------------------------------------------------------------------- function Concat(AList : Var_Args; Arg : Any_Type) return Var_Args; ---------------------------------------------------------------------------- end avcall.register_type; package body avcall.register_type is ---------------------------------------------------------------------------- -- Adds the value in Arg to the next Var_Args.List function Concat(AList : Var_Args; Arg : Any_Type) return Var_Args is Info : Argument_Instance; begin Info.Av_Param := Av_Param_Instance'Access; Info.Instance_Value.all := Arg; Info.Value_Address := Any_Type_Conversion.To_Address(Info.Instance_Value); AList.Count.all := AList.Count.all + 1; AList.List(AList.Count.all) := Argument(Info); return AList; end Concat; ---------------------------------------------------------------------------- end avcall.register_type; with avcall; use avcall; with avcall.register_type; with Ada.Text_IO; use Ada.Text_IO; with System; use System; -------------------------------------------------------------------------------- procedure test_avcall_register_type is procedure Av_Param(AList : System.Address; Value : System.Address) is begin null; end Av_Param; package Int_Registered is new avcall.register_type(Integer, Av_Param); begin Put_Line("FOO"); end test_avcall_register_type; --avcall-register_type.adb:13:34: not subtype conformant with declaration at avcall.ads:37 --avcall-register_type.adb:13:34: formal subprograms not allowed Info.Av_Param := Av_Param_Instance'Access; I don't understand why i can't pass Av_Param to the generic package (in test_call_avcall_register_type.adb) and have its 'Access attribute used in Concat (the offending code in avcall-register_type.adb)?