Prethodna tema :: Sljedeća tema |
Autor/ica |
Poruka |
vsego Site Admin


Pridružen/a: 06. 10. 2002. (22:07:09) Postovi: (3562)16
Spol: 
Lokacija: /sbin/init
|
Postano: 2:13 pet, 7. 4. 2006 Naslov: Vazna napomena za pisanje programa |
|
|
Da biste bili sigurni da je program pisan prema ANSI standardu (dakle, onako kako se traži na zadaćama i kolokvijima):
[list][*] Dev-C++: pod "[tt]Options[/tt]" > "[tt]Compiler options[/tt]" u polje "[tt]Add the following commands when calling compiler[/tt]" stavite:
[tt]-ansi --pedantic-errors[/tt]
[color=#e00000][size=19][b]UPDATE:[/b] Ovo na [u]nekim[/u] verzijama Dev-C++ ne radi :!:[/size]
Idealno je isprobati da li ispravno compilira prvi program s prvih vježbi. :) Ako na tome "pada" compiliranje, iskljucite navedenu opciju i radite bez nje.[/color]
[*] gcc (na Studentu, pod Linuxom i sl): pozivajte compiliranje na slijedeći način:
[tt]gcc -ansi --pedantic-errors <source>.c -o <output>[/tt]
gdje je [tt]<source>.c[/tt] ime datoteke sa source-kodom, a [tt]<output>[/tt] naziv compilirane verzije programa. Na primjer:
[tt]gcc -ansi --pedantic-errors zadaca1_zad1.c -o vsego_zadaca1_zad1[/tt][/list:u]
Inace, zdravo je pratiti sto se dogadja:[list][*]na [url=http://degiorgi.math.hr/c/]sluzbenoj stranici[/url]
[*]na topicu [url=http://degiorgi.math.hr/forum/viewtopic.php?t=6450]DEMONSTRATURE 2005/06[/url]
[*]na topicu aktualne zadace u [url=http://degiorgi.math.hr/forum/viewforum.php?f=32]podforumu kolegija[/url][/list:u]
:kuckkuck:
Da biste bili sigurni da je program pisan prema ANSI standardu (dakle, onako kako se traži na zadaćama i kolokvijima):
- Dev-C++: pod "Options" > "Compiler options" u polje "Add the following commands when calling compiler" stavite:
-ansi –pedantic-errors
UPDATE: Ovo na nekim verzijama Dev-C++ ne radi
Idealno je isprobati da li ispravno compilira prvi program s prvih vježbi. Ako na tome "pada" compiliranje, iskljucite navedenu opciju i radite bez nje.
- gcc (na Studentu, pod Linuxom i sl): pozivajte compiliranje na slijedeći način:
gcc -ansi –pedantic-errors <source>.c -o <output>
gdje je <source>.c ime datoteke sa source-kodom, a <output> naziv compilirane verzije programa. Na primjer:
gcc -ansi –pedantic-errors zadaca1_zad1.c -o vsego_zadaca1_zad1
Inace, zdravo je pratiti sto se dogadja:
_________________ U pravilu ignoriram pitanja u krivim topicima i kodove koji nisu u [code]...[/code] blokovima.
Takodjer, OBJASNITE sto vas muci! "Sto mi je krivo?", bez opisa u cemu je problem, rijetko ce zadobiti moju paznju. 
Zadnja promjena: vsego; 12:00 pet, 7. 4. 2006; ukupno mijenjano 2 put/a.
|
|
[Vrh] |
|
mdoko Forumaš(ica)


Pridružen/a: 30. 11. 2002. (22:17:12) Postovi: (71A)16
Spol: 
Lokacija: Heriot-Watt University, Edinburgh
|
Postano: 2:34 pet, 7. 4. 2006 Naslov: |
|
|
Za one koji zele znati vise:
[quote="[url=http://www.hmug.org/man/1/gcc.php]man gcc[/url]"]
-pedantic
Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++. For ISO C, follows the version of the ISO C standard specified by any -std option used.
Valid ISO C and ISO C++ programs should compile properly with or without this option (though a rare few will require -ansi or a -std option specifying the required version of ISO C). However, without this option, certain GNU extensions and traditional C and C++ features are supported as well. With this option, they are rejected.
-pedantic does not cause warning messages for use of the alternate keywords whose names begin and end with __. Pedantic warnings are also disabled in the expression that follows "__extension__". However, only system header files should use these escape routes; application programs should avoid them.
Some users try to use -pedantic to check programs for strict ISO C conformance. They soon find that it does not do quite what they want: it finds some non-ISO practices, but not all---only those for which ISO C requires a diagnostic, and some others for which diagnostics have been added.
A feature to report any failure to conform to ISO C might be useful in some instances, but would require considerable additional work and would be quite different from -pedantic. We don't have plans to support such a feature in the near future.
Where the standard specified with -std represents a GNU extended dialect of C, such as gnu89 or gnu99, there is a corresponding base standard, the version of ISO C on which the GNU extended dialect is based. Warnings from -pedantic are given where they are required by the base standard. (It would not make sense for such warnings to be given only for features not in the specified GNU C dialect, since by definition the GNU dialects of C include all features the compiler supports with the given option, and there would be nothing to warn about.)
-pedantic-errors
Like -pedantic, except that errors are produced rather than warnings.
[/quote]
Takodjer za vas koji na studentu kompajlirate iz komandne linije preporucam da u [tt].kshrc[/tt] na kraj dodate liniju
[code:1]
alias gcc="gcc -ansi -pedantic-errors"
[/code:1]
Kako bi vam se poziv naredbe [tt]gcc[/tt] automatski mijenjao s [tt]gcc -ansi -pedantic-errors[/tt]
Za one koji zele znati vise:
man gcc (napisa): |
-pedantic
Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++. For ISO C, follows the version of the ISO C standard specified by any -std option used.
Valid ISO C and ISO C++ programs should compile properly with or without this option (though a rare few will require -ansi or a -std option specifying the required version of ISO C). However, without this option, certain GNU extensions and traditional C and C++ features are supported as well. With this option, they are rejected.
-pedantic does not cause warning messages for use of the alternate keywords whose names begin and end with __. Pedantic warnings are also disabled in the expression that follows "__extension__". However, only system header files should use these escape routes; application programs should avoid them.
Some users try to use -pedantic to check programs for strict ISO C conformance. They soon find that it does not do quite what they want: it finds some non-ISO practices, but not all—only those for which ISO C requires a diagnostic, and some others for which diagnostics have been added.
A feature to report any failure to conform to ISO C might be useful in some instances, but would require considerable additional work and would be quite different from -pedantic. We don't have plans to support such a feature in the near future.
Where the standard specified with -std represents a GNU extended dialect of C, such as gnu89 or gnu99, there is a corresponding base standard, the version of ISO C on which the GNU extended dialect is based. Warnings from -pedantic are given where they are required by the base standard. (It would not make sense for such warnings to be given only for features not in the specified GNU C dialect, since by definition the GNU dialects of C include all features the compiler supports with the given option, and there would be nothing to warn about.)
-pedantic-errors
Like -pedantic, except that errors are produced rather than warnings.
|
Takodjer za vas koji na studentu kompajlirate iz komandne linije preporucam da u .kshrc na kraj dodate liniju
Kod: |
alias gcc="gcc -ansi -pedantic-errors"
|
Kako bi vam se poziv naredbe gcc automatski mijenjao s gcc -ansi -pedantic-errors
_________________ Extraordinary claims require extraordinary evidence. – Carl Sagan
Zadnja promjena: mdoko; 4:38 pet, 7. 4. 2006; ukupno mijenjano 1 put.
|
|
[Vrh] |
|
mdoko Forumaš(ica)


Pridružen/a: 30. 11. 2002. (22:17:12) Postovi: (71A)16
Spol: 
Lokacija: Heriot-Watt University, Edinburgh
|
|
[Vrh] |
|
vsego Site Admin


Pridružen/a: 06. 10. 2002. (22:07:09) Postovi: (3562)16
Spol: 
Lokacija: /sbin/init
|
|
[Vrh] |
|
vsego Site Admin


Pridružen/a: 06. 10. 2002. (22:07:09) Postovi: (3562)16
Spol: 
Lokacija: /sbin/init
|
Postano: 12:00 pet, 7. 4. 2006 Naslov: |
|
|
Cini se da neke verzije Dev-C++ imaju gresku zbog koje gornji savjet ne valja. :( Da li radi s vasom verzijom, mozete provjeriti na nekom trivijalnom programu, npr. prvi program iz prvih vjezbi:
[code:1]#include <stdio.h>
int main() {
printf ("Hello world!\n");
return 0;
}[/code:1]
Ako [b]ne[/b] radi, iskljucite opciju i radite bez nje. :)
Isprika ako smo nekog uplasili. :oops:
Cini se da neke verzije Dev-C++ imaju gresku zbog koje gornji savjet ne valja. Da li radi s vasom verzijom, mozete provjeriti na nekom trivijalnom programu, npr. prvi program iz prvih vjezbi:
Kod: | #include <stdio.h>
int main() {
printf ("Hello world!\n");
return 0;
} |
Ako ne radi, iskljucite opciju i radite bez nje.
Isprika ako smo nekog uplasili.
_________________ U pravilu ignoriram pitanja u krivim topicima i kodove koji nisu u [code]...[/code] blokovima.
Takodjer, OBJASNITE sto vas muci! "Sto mi je krivo?", bez opisa u cemu je problem, rijetko ce zadobiti moju paznju. 
|
|
[Vrh] |
|
|