انجمن‌های فارسی اوبونتو

کمک و پشتیبانی => برنامه‌سازی => نویسنده: ha_60 در 08 آبان 1388، 11:14 ق‌ظ

عنوان: مشکل با GCC
ارسال شده توسط: ha_60 در 08 آبان 1388، 11:14 ق‌ظ
سلام
البته دقیقا با avr-gcc مشکل دارم ولی فرقی نباید بکنه
البته با eclipse هم کار می کنم که بازم فکر نکنم مشکل از اون باشه
یه سری کتاب خونست به اسم avrlib که می خوام ازش استفاده کنم یه راهنما هم برای نصب داره
https://ccrma.stanford.edu/courses/250a/docs/avrlib/html/install.html
ولی همین تست خودش هم خطا می ده
In file included from /home/hadi/Projects/avrlib/uart.c:22:
/home/hadi/Projects/avrlib/uart.h:177: error: expected ‘)’ before ‘baudrate’
/home/hadi/Projects/avrlib/uart.h:192: error: expected ‘)’ before ‘data’
مشکل دقیقش توی نحوه include کردن فایل هاست کسی که برنامه رو نوشته انتظار داشه وقتی یه بار یه فایل رو اینکلود می کنه تو بقیه فایل ها هم اینکلود شده به حساب بیاد
//file : examples/rprintf/rprintftest.c
#include "global.h"
#include "uart.h"

//file : examples/rprintf/global.h
#include "avrlibtypes.h"

//file : avrlibtypes.h
typedef unsigned long  u32;

//file : uart.h
177: void uartSetBaudRate(u32 baudrate); //error u32 tarif nashode


به نظر من هم درست می یاد وقتی avrlibtypes یه بار اینکلود شده از تمام توابع تعریف شده تو اون باید بشه تو بقیه فایل های اینکلود شده هم استفاده کرد من اشتباه می کنم؟

عنوان: پاسخ به: مشکل با GCC
ارسال شده توسط: heresh در 08 آبان 1388، 11:37 ق‌ظ
شاید باید از namespace مناسب استفاده کنی. ببین تو هیچ کدوم از فایلهای global.h یا uart.c از namespace استفاده شده؟
تو فایل uart.c فایل "avrlibtypes.h" رو هم اینکلود کن ببین چی میشه  ::)
عنوان: پاسخ به: مشکل با GCC
ارسال شده توسط: ha_60 در 08 آبان 1388، 12:19 ب‌ظ
namespace مال این برنامه های با کلاس ;D ما اینجا کلا ۸ کیلو بایت بیشتر نمی تونیم برنامه بنویسیم به اونجا ها نمی رسه
و با اینکلود کردن درست می شه ولی یکی ۲ تا نیست این برنامه آزمایشی که خودش نوشته می گه برای اینکه تست کنین ببینین درست نصب شده اینو کمپایل کنین حتی makefile رو هم خودش نوشته
در کل می خوام بفهمم مشکل کجاست یعنی از این استاندارد های gcc سر دربیارم
عنوان: پاسخ به: مشکل با GCC
ارسال شده توسط: heresh در 08 آبان 1388، 07:15 ب‌ظ
با چه دستوری کامپایلش می‌کنی؟ همه خروجی ترمینال رو بعدش بنویس
باید پوشه avrlib رو اضافه کنی به لیست کتابخونه‌های نرم‌افزاری که باهاش کد‌ها رو کامپایل می‌کنی
اگه اون کتابخونه‌ها رو کنارش بزاری بازم همون پیام خطا میاد؟
عنوان: پاسخ به: مشکل با GCC
ارسال شده توسط: ha_60 در 08 آبان 1388، 10:47 ب‌ظ
اینم خرجی ولی شما اینو به من بگی مشکلم حل می شه
وقتی من یه فایل رو اینکلود کردم بالای برنامه بعد پایین اون هر فایلی رو اینکلود کنم باید بتونم از محتوییات فایل بالایی استفاده کنم نه؟ من فکر کنم این قابلیت یه جایی باید فعال یا غیر فعال بشه

hadi@jooyeshgar0 ~/Projects/avrlib/examples/rprintf $ make
avr-gcc -c -g -Os -Wall -Wstrict-prototypes -I/home/hadi/Projects/avrlib -Wa,-ahlms=rprintftest.lst -mmcu=atmega163 -I. rprintftest.c -o rprintftest.o
rprintftest.c: In function ‘rprintfTest’:
rprintftest.c:102: warning: pointer targets in passing argument 1 of ‘rprintfStr’ differ in signedness
rprintftest.c:108: warning: pointer targets in passing argument 1 of ‘rprintfStrLen’ differ in signedness
avr-gcc -c -g -Os -Wall -Wstrict-prototypes -I/home/hadi/Projects/avrlib -Wa,-ahlms=/home/hadi/Projects/avrlib/buffer.lst -mmcu=atmega163 -I. /home/hadi/Projects/avrlib/buffer.c -o /home/hadi/Projects/avrlib/buffer.o
avr-gcc -c -g -Os -Wall -Wstrict-prototypes -I/home/hadi/Projects/avrlib -Wa,-ahlms=/home/hadi/Projects/avrlib/uart.lst -mmcu=atmega163 -I. /home/hadi/Projects/avrlib/uart.c -o /home/hadi/Projects/avrlib/uart.o
In file included from /home/hadi/Projects/avrlib/uart.c:22:
/home/hadi/Projects/avrlib/uart.h:177: error: expected ‘)’ before ‘baudrate’
/home/hadi/Projects/avrlib/uart.h:192: error: expected ‘)’ before ‘data’
/home/hadi/Projects/avrlib/uart.h:206: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartReceiveByte’
/home/hadi/Projects/avrlib/uart.h:210: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartReceiveBufferIsEmpty’
/home/hadi/Projects/avrlib/uart.h:218: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartAddToTxBuffer’
/home/hadi/Projects/avrlib/uart.h:227: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartSendBuffer’
/home/hadi/Projects/avrlib/uart.c:26: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartReadyTx’
/home/hadi/Projects/avrlib/uart.c:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartBufferedTx’
/home/hadi/Projects/avrlib/uart.c: In function ‘uartInit’:
/home/hadi/Projects/avrlib/uart.c:52: warning: implicit declaration of function ‘outb’
/home/hadi/Projects/avrlib/uart.c:52: warning: implicit declaration of function ‘BV’
/home/hadi/Projects/avrlib/uart.c:55: warning: implicit declaration of function ‘uartSetBaudRate’
/home/hadi/Projects/avrlib/uart.c:57: error: ‘uartReadyTx’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:57: error: (Each undeclared identifier is reported only once
/home/hadi/Projects/avrlib/uart.c:57: error: for each function it appears in.)
/home/hadi/Projects/avrlib/uart.c:57: error: ‘TRUE’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:58: error: ‘uartBufferedTx’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:58: error: ‘FALSE’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c: In function ‘uartInitBuffers’:
/home/hadi/Projects/avrlib/uart.c:70: warning: pointer targets in passing argument 2 of ‘bufferInit’ differ in signedness
/home/hadi/Projects/avrlib/uart.c:72: warning: pointer targets in passing argument 2 of ‘bufferInit’ differ in signedness
/home/hadi/Projects/avrlib/uart.c: At top level:
/home/hadi/Projects/avrlib/uart.c:89: error: expected ‘)’ before ‘baudrate’
/home/hadi/Projects/avrlib/uart.c:114: error: expected ‘)’ before ‘txData’
/home/hadi/Projects/avrlib/uart.c: In function ‘uartGetByte’:
/home/hadi/Projects/avrlib/uart.c:127: error: ‘u08’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:127: error: expected ‘;’ before ‘c’
/home/hadi/Projects/avrlib/uart.c:128: warning: implicit declaration of function ‘uartReceiveByte’
/home/hadi/Projects/avrlib/uart.c:128: error: ‘c’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c: At top level:
/home/hadi/Projects/avrlib/uart.c:135: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartReceiveByte’
/home/hadi/Projects/avrlib/uart.c:170: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartReceiveBufferIsEmpty’
/home/hadi/Projects/avrlib/uart.c:183: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uartAddToTxBuffer’
/home/hadi/Projects/avrlib/uart.c: In function ‘uartSendTxBuffer’:
/home/hadi/Projects/avrlib/uart.c:193: error: ‘uartBufferedTx’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:193: error: ‘TRUE’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:195: warning: implicit declaration of function ‘uartSendByte’
/home/hadi/Projects/avrlib/uart.c: In function ‘__vector_13’:
/home/hadi/Projects/avrlib/uart.c:233: error: ‘uartBufferedTx’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:244: error: ‘FALSE’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:246: error: ‘uartReadyTx’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:246: error: ‘TRUE’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c: In function ‘__vector_11’:
/home/hadi/Projects/avrlib/uart.c:260: error: ‘u08’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:260: error: expected ‘;’ before ‘c’
/home/hadi/Projects/avrlib/uart.c:263: error: ‘c’ undeclared (first use in this function)
/home/hadi/Projects/avrlib/uart.c:263: warning: implicit declaration of function ‘inb’
make: *** [/home/hadi/Projects/avrlib/uart.o] Error 1
rm /home/hadi/Projects/avrlib/buffer.o
عنوان: پاسخ به: مشکل با GCC
ارسال شده توسط: mozhdeh در 13 آبان 1388، 01:26 ق‌ظ
نقل‌قول
وقتی من یه فایل رو اینکلود کردم بالای برنامه بعد پایین اون هر فایلی رو اینکلود کنم باید بتونم از محتوییات فایل بالایی استفاده کنم نه؟ من فکر کنم این قابلیت یه جایی باید فعال یا غیر فعال بشه

منظورتون اینه که اگه تو فایل x، فایل a و فایل b رو include کنید، فایل a تو فایل b هم include بشه؟
خوب توی c اینطور نیست، دلیلش هم می‌تونه این باشه که این فایل‌ها جداگانه کامپایل می‌شن و بعد از کامپایل به هم لینک می‌شن. یعنی کامپایلر نمی‌یاد بگرده ببینه جایی که از b استفاده شده قبلش a هم include شده باشه.
عنوان: پاسخ به: مشکل با GCC
ارسال شده توسط: ha_60 در 13 آبان 1388، 08:08 ق‌ظ
من بیشتر php کار می کنم توی php که اینجوری نیست
ولی حرف شما هم منطقی به نظر می یاد
این کتابخونه ها کار دانشگاه استنفرد بنابراین مشکل توی کتاب خونه ها نیست و اون فایل ها هم به اون سبک تعریف نشدن یه چیزی یه جایی هست که من نمی دونم
اگه یه نفر یه تست بکنه ببینه مشکل کجاست خیلی خوبه از توی ریپوزیتوری باید avr-gcc , avr-libc رو نصب کنید راهنمای نصب این هم هست ممنون می شم