Error old style parameter declarations in prototyped function definition

Соообщение # error "Attempt to include more than one file ATmega AVR Решение и ответ на вопрос 2258828

nik-el

0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

1

04.06.2018, 17:24. Показов 3486. Ответов 15

Метки нет (Все метки)


Помогите разобраться где косяк
Atmel Studio 7 C++
выдает сообщения … , в том числе: # error «Attempt to include more than one <avr/ioXXX.h> file
по двум кликам перехожу из main.c в iotn1616.h в строку ( <=== )
——— iotn1616.h ———————-

C++
1
2
3
4
5
6
7
8
9
#ifndef _AVR_IO_H_
#  error "Include <avr/io.h> instead of this file."
#endif
 
#ifndef _AVR_IOXXX_H_
#  define _AVR_IOXXX_H_ "iotn1616.h"
#else
#  error "Attempt to include more than one <avr/ioXXX.h> file."    <===
#endif

. . . .
——————————————-

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

05.06.2018, 06:36

2

смотри где определен макрос _AVR_IOXXX_H_



0



nik-el

0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

05.06.2018, 09:57

 [ТС]

3

1. макрос _AVR_IOXXX_H_ поиском по всему проекту не обнаружен
2. сочетание «avr/io» поиском по всему проекту обнаружено в iotn1616.h (см. выше), и еще в compiler.h и в assembler.h
— compiler.h —

C
1
2
3
4
#if defined(__GNUC__)
#include <avr/io.h>
 . . . . . . . .
#endif

— assembler.h —

C
1
2
3
4
5
6
7
#if defined(__ASSEMBLER__)
#include "assembler/gas.h"
#include <avr/io.h>
#elif defined(__IAR_SYSTEMS_ASM__)
#include "assembler/iar.h"
#include <ioavr.h>
#endif

Добавлено через 35 минут
поправка — макрос _AVR_IOXXX_H_ поиском по всему решению обнаружен в iotn1616.h (см. #1)



0



Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

05.06.2018, 10:58

4

Цитата
Сообщение от nik-el
Посмотреть сообщение

в iotn1616.h (см. #1)

кусок кода в первом сообщении оттуда?



0



0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

05.06.2018, 11:37

 [ТС]

5

из самого начала файла iotn1616.h — это описание tiny1616
в «Обозревателе решений» его не видно, но по «ошибке» можно перейти в него



0



ValeryS

Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

05.06.2018, 11:49

6

Цитата
Сообщение от nik-el
Посмотреть сообщение

из самого начала файла iotn1616.h

тогда ищи где он включен 2 и более раз
ибо код прямо говорит

Цитата
Сообщение от nik-el
Посмотреть сообщение

C
1
2
3
4
5
#ifndef _AVR_IOXXX_H_
#  define _AVR_IOXXX_H_ "iotn1616.h"
#else
#  error "Attempt to include more than one <avr/ioXXX.h> file."
#endif

если макрос _AVR_IOXXX_H_ не определен то определить его как «iotn1616.h»
иначе вызвать ошибку «Attempt to include more than one <avr/ioXXX.h> file.»
которая кстати так и переводится

Попытка включить более одного файла <avr / ioXXX.h>



1



nik-el

0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

05.06.2018, 12:43

 [ТС]

7

Спасибо, буду искать

Добавлено через 1 минуту
и еще 1 бяка http://www.cyberforum.ru/avr/t… st12450903

Добавлено через 5 минут

Цитата
Сообщение от ValeryS
Посмотреть сообщение

если макрос _AVR_IOXXX_H_ не определен то определить его как «iotn1616.h»

а разве хедер м.б. макросом или это нюансы С ?

Добавлено через 7 минут
в самом начале «iotn1616.h» написано:

C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef _AVR_IO_H_
#  error "Include <avr/io.h> instead of this file."
#endif
 
#ifndef _AVR_IOXXX_H_
#  define _AVR_IOXXX_H_ "iotn1616.h"
#else
#  error "Attempt to include more than one <avr/ioXXX.h> file."
#endif
 
#ifndef _AVR_ATTINY1616_H_INCLUDED
#define _AVR_ATTINY1616_H_INCLUDED
 
/* Ungrouped common registers */
#define CCP  _SFR_MEM8(0x0034)  /* Configuration Change Protection */
#define SPH  _SFR_MEM8(0x003E)  /* Stack Pointer High */
#define SPL  _SFR_MEM8(0x003D)  /* Stack Pointer Low */
#define SREG  _SFR_MEM8(0x003F)  /* Status Register */
и  т.д.

Добавлено через 2 минуты
а где тогда вписать определение макроса _AVR_IOXXX_H_ ?
в «assembler.h» и/или «compiler.h»

Добавлено через 25 минут
собственно весь compiler.h это:

C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef UTILS_COMPILER_H
#define UTILS_COMPILER_H
 
/**
 * defgroup doc_driver_utils_compiler Compiler abstraction
 * ingroup doc_driver_utils
 *
 * Compiler abstraction layer and code utilities for 8-bit AVR.
 * This module provides various abstraction layers and utilities
 * to make code compatible between different compilers.
 *
 * {
 */
 
#if defined(__GNUC__)
#include <avr/io.h>
#include <avr/builtins.h>
#elif defined(__ICCAVR__)
#define ENABLE_BIT_DEFINITIONS 1
#include <ioavr.h>
#include <intrinsics.h>
 
#ifndef CCP_IOREG_gc
#define CCP_IOREG_gc 0xD8 /* CPU_CCP_IOREG_gc */
#endif
#ifndef CCP_SPM_gc
#define CCP_SPM_gc 0x9D /* CPU_CCP_SPM_gc */
#endif
 
#else
#error Unsupported compiler.
#endif
 
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
 
#include <interrupt_avr8.h>
 
/**
 * def UNUSED
 * brief Marking a v as a unused parameter or value.
 */
#define UNUSED(v) (void)(v)
 
#endif /* UTILS_COMPILER_H */

Добавлено через 1 минуту
а assembler.h

C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef ASSEMBLER_H_INCLUDED
#define ASSEMBLER_H_INCLUDED
 
#if !defined(__ASSEMBLER__) && !defined(__IAR_SYSTEMS_ASM__) && !defined(__DOXYGEN__)
#error This file may only be included from assembly files
#endif
 
#if defined(__ASSEMBLER__)
#include "assembler/gas.h"
#include <avr/io.h>
#elif defined(__IAR_SYSTEMS_ASM__)
#include "assembler/iar.h"
#include <ioavr.h>
#endif
 
#endif /* ASSEMBLER_H_INCLUDED */



0



nik-el

0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

07.06.2018, 14:13

 [ТС]

8

файл iotn1616.h лежит не в проекте а в самой студии
C:Program Files (x86)AtmelStudio7.0PacksatmelATtiny_DFP1.3. 172includeavriotn1616.h
причем есть 6 версий от …ATtiny_DFP1.2.112 до …ATtiny_DFP1.3.172
подключается самая свежая

C
1
2
#ifndef _AVR_IOXXX_H_
#  define _AVR_IOXXX_H_ "iotn1616.h"

а если что не так то:

C
1
2
3
#else
#  error "Attempt to include more than one <avr/ioXXX.h> file."
#endif

Добавлено через 5 минут
и что это такое — глюк студии, который она сама же и соорудила или надо iotn1616.h «привязать» к проекту заново?

Добавлено через 4 часа 11 минут
в самом начале main.c есть вот такое:

C
1
2
3
4
5
6
#include <atmel_start.h>
#include "atomic.h"
#include "avriotn1616.h"
#include "main.h"
 
//  Extern variables



0



ValeryS

Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

07.06.2018, 14:19

9

Цитата
Сообщение от nik-el
Посмотреть сообщение

в самом начале main.c есть вот такое:

попробуй вот это выбросить

Цитата
Сообщение от nik-el
Посмотреть сообщение

C
1
#include "avriotn1616.h"



0



nik-el

0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

08.06.2018, 09:29

 [ТС]

10

я конечно попробовал, хоть и сомневался что это правильно
вот результат + 6 ошибок

1. multiple definition of `key_status’
2. recipe for target ‘Attiny1616_klava12cod2.elf’ failed
3. multiple definition of `touch_example’
4. undefined reference to `GET_MUTLCAP_SENSOR_NOISE_STATUS’
5. undefined reference to `GET_MUTLCAP_SENSOR_MOIS_STATUS’
6. ld returned 1 exit status

Добавлено через 44 минуты
3. multiple definition of `touch_example’
указывает на строчку (№59)

C
1
    ENABLE_INTERRUPTS();

это бред какой то

Добавлено через 17 часов 6 минут
за «основу» программы я взял пример из инета «Reading sensor moisture and noise states»

C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 if(! (GET_MUTLCAP_SENSOR_NOISE_STATUS(SENSOR_NUMBER)))
    {
    if(! (GET_MUTLCAP_SENSOR_MOIS_STATUS (SENSOR_NUMBER)))
       {
        /*Sensor state is valid Read sensor state */
       }
    else
       {
        /* Sensor is Moisture affected*/
       }
    }
 else
     {
    /* Sensor is noisy */
     }

этот код может как то не состыковаться с С++ в АтмелСтудии7 ?



0



ValeryS

Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

08.06.2018, 09:41

11

Цитата
Сообщение от nik-el
Посмотреть сообщение

за «основу» программы я взял пример из инета

и весь состоит из макросов
напиши для начала простой

C
1
2
3
4
5
6
int main()
{
 while(1)
  {
  }
}

без конкретного микропроцессора
потом добавь микропроцессор
потом свой код постепенно
и смотри на каком этапе вылазят ошибки



0



nik-el

0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

08.06.2018, 13:32

 [ТС]

12

Спасибо, но я уже выбрал контроллер под конкретную задачу и через Атмел Старт настроил/создал проект, прогу, но
регулярно запинаюсь из-за разных подходов(в примерах) в программировании на С / С++ и для разных сред

Добавлено через 19 минут

C
1
2
3
4
 . . .
// Global variables
bool GET_MUTLCAP_SENSOR_NOISE_STATUS(uint8_t SENSOR_NUMBER)
. . .

Добавлено через 23 минуты
на строчку №3 ругается так:
Ошибка old-style parameter declarations in prototyped function definition



0



0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

18.06.2018, 11:39

 [ТС]

13

к «регулярно запинаюсь из-за разных подходов(в примерах) в программировании на С / С++ и для разных сред»
можно добавить «и за разные годы издания фирменной документации»
короче, попадалово



0



Arhat109

-28 / 20 / 2

Регистрация: 18.06.2018

Сообщений: 199

20.06.2018, 12:36

14

Не знаю как там в Атмел студии, но вообще-то хидеры, определяющие микроконтроллер напрямую в main не включаются, а подключаются автоматом через общий хидер io.h.

Тип микроконтроллера надо указывать не подключаемым хидером, а символом #define соответственно типу кристалла, типа так:

C
1
2
#define __AVR_MEGA2560__ // тот символ, что соответствует вашему микроконтроллеру.
#include <io.h>

Скорее всего, достаточно писать короче, только include. а символ с меткой кристалла укажет сама Студия, где наверняка есть в проекте «тип камня», который надо вырать для настройки проекта .. хотя тут — не знаю, не работал с ней.



0



0 / 0 / 0

Регистрация: 04.06.2018

Сообщений: 16

03.07.2018, 16:36

 [ТС]

15

Цитата
Сообщение от Arhat109
Посмотреть сообщение

«тип камня»

и многое др. задаются в AtmelStart
на строчку

Цитата
Сообщение от nik-el
Посмотреть сообщение

bool GET_MUTLCAP_SENSOR_NOISE_STATUS(uint8_t SENSOR_NUMBER)

ругается так:
Ошибка old-style parameter declarations in prototyped function definition
оказалось что надо поставить ;



0



0 / 0 / 0

Регистрация: 23.02.2016

Сообщений: 4

05.04.2022, 21:17

16

я сначала не понял почему ругалось на
error «Attempt to include more than one <avr/ioXXX.h> file.»
в файле
#include «avriotn1616.h»

Потом понял, я ж в свойствах проекта задал Device, поэтому автоматом подгрузилась соответствующая библиотека (в свойствах проекта в разделе Packs это видно в Header), а я в main.c ее второй раз как бы подключаю, поэтому макрос _AVR_IOXXX_H_ уже определен и вылезает ошибка



0



Prototype function definition

Hi, i am using a tool developed in C and i use «make all» command to run. But the following error occur:

cc -O -DUNIX -DBSD -g -I/home/English/morph-1.5/hash -I/usr/include/X11/Xaw -c -w -o lib/bcopy.o /home/English/morph-1.5/hash/bcopy.c
/home/English/morph-1.5/hash/bcopy.c: In function �bcopy�:
/usr/include/bits/string3.h:90: error: old-style parameter declarations in prototyped function definition
make: *** [lib/bcopy.o] Error 1

and the program is given below

#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = «@(#)bcopy.c 5.7 (Berkeley) 5/16/90»;
#endif /* LIBC_SCCS and not lint */

#include <string.h>
#include <sys/types.h>

/*
* sizeof(word) MUST BE A POWER OF TWO
* SO THAT wmask BELOW IS ALL ONES
*/
typedef int word; /* «word» used for optimal copy speed */

#define wsize sizeof(word)
#define wmask (wsize — 1)

/*
* Copy a block of memory, handling overlap.
* This is the routine that actually implements
* (the portable versions of) bcopy, memcpy, and memmove.
*/
void bcopy(const void *src0, void *dst0, size_t length)
//void bcopy( src0, dst0, length)
char *dst0;
char *src0;
register size_t length;
{
register char *dst = dst0;
register char *src = src0;
register size_t t;

if (length == 0 || dst == src) /* nothing to do */
return;

/*
* Macros: loop-t-times; and loop-t-times, t>0
*/
#define TLOOP(s) if (t) TLOOP1(s)
#define TLOOP1(s) do { s; } while (—t)

if ((unsigned long)dst < (unsigned long)src) {
/*
* Copy forward.
*/
t = (int)src; /* only need low bits */
if ((t | (int)dst) & wmask) {
/*
* Try to align operands. This cannot be done
* unless the low bits match.
*/
if ((t ^ (int)dst) & wmask || length < wsize)
t = length;
else
t = wsize — (t & wmask);
length -= t;
TLOOP1(*dst++ = *src++);
}
/*
* Copy whole words, then mop up any trailing bytes.
*/
t = length / wsize;
TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
t = length & wmask;
TLOOP(*dst++ = *src++);
} else {
/*
* Copy backwards. Otherwise essentially the same.
* Alignment works as before, except that it takes
* (t&wmask) bytes to align, not wsize-(t&wmask).
*/
src += length;
dst += length;
t = (int)src;
if ((t | (int)dst) & wmask) {
if ((t ^ (int)dst) & wmask || length <= wsize)
t = length;
else
t &= wmask;
length -= t;
TLOOP1(*—dst = *—src);
}
t = length / wsize;
TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
t = length & wmask;
TLOOP(*—dst = *—src);
}
return;
}


Re: Prototype function definition

Moved to «Programming Talk»


Re: Prototype function definition

Quote Originally Posted by grk.jkb
View Post

Hi, i am using a tool developed in C and i use «make all» command to run. But the following error occur:

cc -O -DUNIX -DBSD -g -I/home/English/morph-1.5/hash -I/usr/include/X11/Xaw -c -w -o lib/bcopy.o /home/English/morph-1.5/hash/bcopy.c
/home/English/morph-1.5/hash/bcopy.c: In function �bcopy�:
/usr/include/bits/string3.h:90: error: old-style parameter declarations in prototyped function definition
make: *** [lib/bcopy.o] Error 1

Code:

void bcopy(const void *src0, void *dst0, size_t length)
//void bcopy( src0, dst0, length)
    char *dst0;
    char *src0;
    register size_t length;    
{

That’s were the error is occuring, like the message said, old-style (pre-ANSI) parameter declarations mixed with prototyped (ANSI) function definition.
Two quick solutions here: either remove the prototyped definition and uncomment the old-style definition:

Code:

//void bcopy(const void *src0, void *dst0, size_t length)
void bcopy( src0, dst0, length)
    char *dst0;
    char *src0;
    register size_t length;    
{

or use the new-style prototyped function defintion:

Code:

void bcopy(const void *src0, void *dst0, size_t length)
/* void bcopy( src0, dst0, length)
    char *dst0;
    char *src0;
    register size_t length;    
*/
{

I would go for the prototyped function definition, unless you need portability to old systems without an ANSI/ISO-C compliant compiler.

Another way is this:

Code:

#ifdef __STDC__
void bcopy(const void *src0, void *dst0, size_t length)
#else
void bcopy( src0, dst0, length)
    char *dst0;
    char *src0;
    register size_t length;    
#endif
{

This will pick the prototyped version for ANSI/ISO-C compliant compilers and the old definition syntax for pre-ANSI/ISO compilers.

Additional nitpick: C++-style comments (//) are accepted in C99 and GNU-C, but illegal in C90, so if you want maximum portability you should avoid those.

Hope this helps.

«When in doubt, use brute force.»

— Ken Thompson


  • #1

I’m unable to upgrade to the latest version of

lsof

.

Code:

ckkv.c:58: error: old-style parameter declarations in prototyped function definition
/usr/include/xlocale/_time.h:45: error: parameter name omitted
/usr/include/xlocale/_time.h:45: error: parameter name omitted
/usr/include/xlocale/_time.h:45: error: parameter name omitted
/usr/include/xlocale/_time.h:46: error: parameter name omitted
/usr/include/xlocale/_time.h:46: error: parameter name omitted
ckkv.c:61: error: storage size of 'u' isn't known
ckkv.c:63: error: 'Fwarn' undeclared (first use in this function)
ckkv.c:70: error: 'Pn' undeclared (first use in this function)
ckkv.c:73: error: 'er' undeclared (first use in this function)
ckkv.c:76: error: 'd' undeclared (first use in this function)
ckkv.c:78: error: 'ev' undeclared (first use in this function)
ckkv.c:83: error: 'ea' undeclared (first use in this function)
*** [ckkv.o] Error code 1

Stop in /usr/ports/sysutils/lsof/work/lsof_4.87/lsof_4.87_src/lib.
*** [lib/liblsof.a] Error code 1

Stop in /usr/ports/sysutils/lsof/work/lsof_4.87/lsof_4.87_src.
*** [do-build] Error code 1

Stop in /usr/ports/sysutils/lsof.
[8]root@test:/usr/ports/sysutils/lsof #

I’ve uninstalled and reinstalled to no avail. What am I doing wrong?

Running FreeBSD 9.0-STABLE #6.

~Doug

  • #2

dougs said:

Code:

ckkv.c:58: error: old-style parameter declarations in prototyped function definition

I portsnapped, fetched the source and had a look at this file. It does indeed contain a K&R-style function header which is pretty much antiquated by now. A quick fix would be to change it into the current function format: instead of

Code:

void
ckkv(d, er, ev, ea)
  char *d;
  char *er;
  char *ev;
  char *ea;
{
  [i]...[/i]
}

make it

Code:

void
ckkv(char *d, char *er, char *ev, char *ea)
{
  [i]...[/i]
}

Or alternatively, there’s probably a compiler option somewhere that tells gcc (assuming that’s the compiler you use) to accept old-style K&R function headers.

If you cannot program in C and/or there are several more of these old-style definitions, post the contents of

/etc/make.conf

if there’s anything in there. If not, I suggest you notify the port maintainer of the problem because in that case (s)he should probably update the port so that others don’t run into the same problem.

Hope this helps,

Fonz

  • #3

To followup: the port in question compiles just fine on the 8.2-RELEASE/amd64 system I’m on at the moment, so I strongly suspect there’s a compiler option issue somewhere in all of this.

Fonz

wblock@


  • #4

Builds without errors or warnings on 9-STABLE amd64.

  • Thread Starter

  • #5

Code:

[11]root@test:/usr/ports/sysutils/lsof # less /etc/make.conf
WITHOUT_X11=yes
#  
# Keep ruby 1.8 as default version.  
#  
RUBY_DEFAULT_VER=1.8  
# added by use.perl 2012-03-09 14:05:39
PERL_VERSION=5.14.2

Can someone walk me through the compiler options? I’m not versed in compiling at all. I just follow what the handbook tells me in upgrading ports. :(

I’m on 9.0-STABLE x86.

~Doug

wblock@


  • #6

It should just be

Code:

# cd /usr/ports/sysutils/lsof
# make install clean

It’s hard to tell what’s causing that error. If some odd compiler flags were set, they would usually be in

/etc/make.conf

. What customizations have you done to the system? 9.0-STABLE as of what date? Has the system been compiled since

/usr/src

was last updated?

  • #7

Also, is your ports tree up to date?

Fonz

  • Thread Starter

  • #8

Um, it’s possible that I may have run

svn

and then decided not to build world/kernel.

Code:

[14]root@test:/usr/src # svn info
Path: .
Working Copy Root Path: /usr/src
URL: http://svn0.us-west.freebsd.org/base/releng/9.0
Repository Root: http://svn0.us-west.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 243633
Node Kind: directory
Schedule: normal
Last Changed Author: simon
Last Changed Rev: 243417
Last Changed Date: 2012-11-22 14:52:15 -0800 (Thu, 22 Nov 2012)

[14]root@test:/usr/src #

This machine is one of two 9.0-STABLE machines here at work— the rest are 9.0-RELEASE.

I will do another

svn

and rebuild after this weekend. I’ll report how it turns out.

Oh, and yes, the ports are up-to-date. I run portsnap fetch/update once a week.

~Doug

wblock@


  • #9

That is probably not the problem, but it’s good to make sure source and binary are the same.

  • Thread Starter

  • #10

So I ran

svn

and rebuilt world/kernel. Now I can install and execute

lsof

just fine. Egads.

~Doug

  • #11

If I remember rightly lsof actually uses files found in

/usr/src

during compilation. I suspect if these files are different to the actual files installed in the base system then there might be some conflict there. You suggest you svn’d without installing a new world/kernel so I guess that’s the case.

DutchDaemon


  • #12

Yes, I believe

lsof

requires the kernel source files to be in accordance with the actual kernel.

Понравилась статья? Поделить с друзьями:
  • Error oid not increasing
  • Error oib already exists in point
  • Error office version как убрать
  • Error office version 2007
  • Error of set pic flash addr