gbowne1 / random_c_cpp_programs

A collection of my random opensource C and C++ programs
MIT License
3 stars 6 forks source link

[Bug] polynomialring.c has multiple issues #48

Open gbowne1 opened 1 month ago

gbowne1 commented 1 month ago

$ gcc -Wall -Wextra -pedantic -std=c99 -O2 polynomialring.c -o ../build/polynomialring polynomialring.c: In function ‘multiplyPolynomials’: polynomialring.c:100:13: warning: implicit declaration of function ‘addTerm’ [-Wimplicit-function-declaration] addTerm(result, &term); ^~~ polynomialring.c: At top level: polynomialring.c:107:6: warning: conflicting types for ‘addTerm’ void addTerm(Polynomial poly, Term term) { ^~~ polynomialring.c:100:13: note: previous implicit declaration of ‘addTerm’ was here addTerm(result, &term); ^~~ polynomialring.c: In function ‘addTerm’: polynomialring.c:113:5: warning: implicit declaration of function ‘memmove’ [-Wimplicit-function-declaration] memmove(&poly->terms[index+1], &poly->terms[index], (poly->degree-index)*sizeof(Term)); ^~~ polynomialring.c:113:5: warning: incompatible implicit declaration of built-in function ‘memmove’ polynomialring.c:113:5: note: include ‘’ or provide a declaration of ‘memmove’ polynomialring.c:9:1: +#include

polynomialring.c:113:5: memmove(&poly->terms[index+1], &poly->terms[index], (poly->degree-index)sizeof(Term)); ^~~ polynomialring.c: In function ‘main’: polynomialring.c:145:18: warning: passing argument 1 of ‘freePolynomial’ from incompatible pointer type [-Wincompatible-pointer-types] freePolynomial(&sum); ^~~~ polynomialring.c:45:33: note: expected ‘Polynomial ’ {aka ‘struct Polynomial ’} but argument is of type ‘Polynomial ’ {aka ‘struct Polynomial ’} void freePolynomial(Polynomial poly) {


polynomialring.c:157:18: warning: passing argument 1 of ‘freePolynomial’ from incompatible pointer type [-Wincompatible-pointer-types]
   freePolynomial(&product);
                  ^~~~~~~~
polynomialring.c:45:33: note: expected ‘Polynomial *’ {aka ‘struct Polynomial *’} but argument is of type ‘Polynomial **’ {aka ‘struct Polynomial **’}
 void freePolynomial(Polynomial *poly) {
                     ~~~~~~~~~~~~^~~~
polynomialring.c:160:17: warning: passing argument 1 of ‘freePolynomial’ from incompatible pointer type [-Wincompatible-pointer-types]
  freePolynomial(&poly1);
                 ^~~~~~
polynomialring.c:45:33: note: expected ‘Polynomial *’ {aka ‘struct Polynomial *’} but argument is of type ‘Polynomial **’ {aka ‘struct Polynomial **’}
 void freePolynomial(Polynomial *poly) {
                     ~~~~~~~~~~~~^~~~
polynomialring.c:161:17: warning: passing argument 1 of ‘freePolynomial’ from incompatible pointer type [-Wincompatible-pointer-types]
  freePolynomial(&poly2);
                 ^~~~~~
polynomialring.c:45:33: note: expected ‘Polynomial *’ {aka ‘struct Polynomial *’} but argument is of type ‘Polynomial **’ {aka ‘struct Polynomial **’}
 void freePolynomial(Polynomial *poly) {
                     ~~~~~~~~~~~~^~~~