2017-05-05 3 views
4

廃止されました:C関数は、私はリンクの下でコードを使用

Readline Library

そして、私は、コンパイラはこれらの警告を表示するコードをコンパイルするとき、私はこの

typedef struct { 
    char *name;   /* User printable name of the function. */ 
    Function *func;  /* Function to call to do the job. */ 
    char *doc;   /* Documentation for this function. */ 
} COMMAND; 

のような構造体を定義した:

"機能は推奨されていません[-Wdeprecated-declarations]

機能タイプを使用できない場合、どのタイプを変更する必要がありますか?

typedef int Function() __attribute__ ((deprecated)); 

ちょうど使用します:

typedef struct { 
    char *name;   /* User printable name of the function. */ 
    int (*func)();   /* Function to call to do the job. */ 
    char *doc;    /* Documentation for this function. */ 
} COMMAND; 
+0

あなたは[___MCVE___](http://stackoverflow.com/help/mcve)を作成しても構いませんか? –

+0

あなたが得た*完全な正確なエラーは何ですか? –

+0

警告メッセージを見て、それはまた、廃止された機能を教えてくれるでしょう –

答えて

6

Functionlibraryで廃止予定としてマークさtypedefintを返す関数へのポインタのエイリアス)です。そして、次のことが働く可能性があります。

#include <stdio.h> 

typedef void (*Function)(); 

typedef struct { 
    char *name;   /* User printable name of the function. */ 
    Function *func;  /* Function to call to do the job. */ 
    char *doc;   /* Documentation for this function. */ 
}COMMAND; 

int main() { 
    COMMAND commond; 

    puts("end"); 



    return 0; 
} 
-3

私はあなたが機能を廃止すべきだと思う

+0

私の投票ではありませんが...この提案の問題は、コードが(typedefを含む)ヘッダを使用して'Function'であるが、 'deprecated'と注釈されている(これは使わないことを意味する)。他のヘッダーが含まれていると、コードが正しく動作しません。 –

+0

すみません。私は新しいコーダーです。私は英語で勉強しています。 –

関連する問題