O
O
Oleg Filimonenko2019-02-11 22:48:41
C++ / C#
Oleg Filimonenko, 2019-02-11 22:48:41

Declaring an identifier #define in a function prototype in C (C), is it possible to do this?

Hello! There is a question: is it allowed to declare a #define identifier in a function prototype in C.
Textbook by Brian Kernighan and Dennis Ritchie, second edition, paragraph 1.9 (Character Arrays). The paragraph considers an example of using functions with arrays passed to them as arguments. The program uses a preprocessor directive to declare a named constant, which is used a few lines below when describing a function prototype.

#include <stdio.h>

#define MAXLINE 500

int get(char line[], int MAXLINE); // В этой строке линтер жалуется на "ожидаемую )". Линковщик спотыкается  на этом же месте.
void copy(char to[], char from[]);

IDE: QT Creator 4.8.1
Engine: QT 5.12.0
GCC: 5.3.1
Maybe this is a mismatch between C99 and C11 standards? Is there any way to mitigate this misunderstanding?
Who has any thoughts on this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-02-11
@Redproxima

Oleg Filimonenko ,

you have a wrong translation
ОНА?
Автор: Б. Керниган, Д. Ритчи (Перевод с английского Вт. С. Штаркмана, под редакцией Вс. С. Штаркмана.)
Год: 1992
ISBN: 5-7940-0045-7
Тут еще:
...
function prototype:
Year: 2009
Author: Kernighan B., Ritchie D. / Kernighan B., Ritchie D.
Publisher: Williams
ISBN: 978-5-8459-0891-9
Год издания: 1978
Автор: Kerninghan, Brian W.
Издательство: Bell Telephone Laboratories
ISBN: 0-13-110163-3
Язык: Английский
5c61e83b28570703220686.png5c61e8f0e2cc4890842644.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question