Warnungen bei struct



  • Hi, da ich erst seit kurzem in c programmiere, verstehe ich diese Warnung nicht.

    --------------------Configuration: GTI_Praktikum - Win32 Debug--------------------
    Compiling...
    GTI_Praktikum.c
    D:\Programmierungskram\C-Kram\Praktikum\GTI_Praktikum.c(20) : warning C4133: 'function' : incompatible types - from 'struct MINTERM ** ' to 'struct minterm ** '
    D:\Programmierungskram\C-Kram\Praktikum\GTI_Praktikum.c(23) : warning C4133: '=' : incompatible types - from 'struct MINTERM *' to 'struct minterm *'
    D:\Programmierungskram\C-Kram\Praktikum\GTI_Praktikum.c(30) : warning C4133: 'function' : incompatible types - from 'struct MINTERM ** ' to 'struct minterm ** '
    Linking...

    GTI_Praktikum.exe - 0 error(s), 3 warning(s)

    Hier das Programm

    Main Datei:

    #include "prototypen.h"
    
    int anzahl_variablen = 0, anzahl_minterme = 0;
    struct MINTERM *einlesen_head, *primterm_head, *min_head = NULL;
    
    int main(void) {
    
    	short int testfeld[10];
    	int i,j;
    	MINTERM *neu, *ptr;
    
    	for(i = 0; i <= 9; i++) {
    		testfeld[i] = 0;
    	}
    
    	neu = create_minterm_list_element(testfeld);
    	add_minterm_list_element(neu,&min_head);
    
    	for(ptr = min_head; ptr != NULL; ptr = ptr->next) {
    		printf("verwendet: %d\n",ptr->verwendet);
    		for(j=0;j<=9;j++) {
    			printf("Element %d : %d \n",j,ptr->bit[i]);
    		}
    	}
    
    	delete_minterm_list_element(neu , &min_head);
    
    return 0;
    
    }
    

    prototypen header:

    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    #ifndef prototypen
    #define MAX_VARIABLEN 10 
    #define MAX_DATEI 30
    
    typedef struct komposition 
    {
    	int entstanden_aus;
    	struct komposition *next;
    } KOMPOSITION;
    
    typedef struct minterm
    {
    	short int bit[MAX_VARIABLEN];
    	short int verwendet;
    	KOMPOSITION *komp_head;
    	struct minterm *next;
    } MINTERM;
    
    	MINTERM *create_minterm_list_element(short int[]);
    	void delete_minterm_list_element(MINTERM *,MINTERM **);
    	void add_minterm_list_element(MINTERM *, MINTERM **);
    
    #endif
    

    create_minterm Datei:

    #include "prototypen.h"
    
    MINTERM *create_minterm_list_element(short int aus_bit[]) {
    
    	int i = 0;
    	MINTERM *neu;
    	neu = (MINTERM*)malloc(sizeof(MINTERM));
    	if(neu == NULL) {
    		printf("create_minterm_list_element: malloc failed\n");
    		exit(1);
    	} else {
    		neu->verwendet = 1;
    		for(i=0;i<=9;i++) {
    			neu->bit[i]=aus_bit[i];
    		}
    
    	}
    	neu->next = NULL;
    	return neu;
    
    }
    

    add_minterm Datei:

    #include "prototypen.h"
    
    void add_minterm_list_element(MINTERM *neu, MINTERM **ptrptr)
    {
    	MINTERM *ptr;
    
    	if(*ptrptr == NULL) {
    		*ptrptr = neu;
    	} else {
    		for(ptr = *ptrptr; ptr->next != NULL; ptr=ptr->next)
    			;
    		ptr->next = neu;
    	}
    	return;
    }
    

    delete_minterm Datei:

    #include "prototypen.h"
    
    void delete_minterm_list_element(MINTERM * del_ptr, MINTERM **ptrptr) {
    
    	MINTERM *ptr;
    
    	if(del_ptr == *ptrptr) {
    		*ptrptr = del_ptr->next;
    	} else {
    		for(ptr = *ptrptr; (ptr != NULL) && (ptr->next != del_ptr);ptr = ptr->next)
    			;
    		if(ptr == NULL) {
    			printf("delete_minterm_list_element: can`t find list_\n");
    			exit(3);
    		} else {
    			ptr->next = ptr->next->next;
    		}
    	}
    	/* Freigebe des Speicherbereiches */
    	free(del_ptr);
    	return;
    
    }
    


  • Hab' ne Ahnung...
    Benenn doch bitte mal "GTI_Praktikum.c" in "GTI_Praktikum.cpp" um.

    Greetz, Swordfish



  • ich hab da auch ne ahnung: deine prototypen.h ist falsch. lies die fehler nochmal. du wirst eventuell erkennen, dass dort gross/kleinschreibung das problem ist.



  • @c.rackwitz: Verarsch mich nicht... 🙄

    Er hat doch ein typedef für MINTERM (ja, groß geschrieben 😉 ) gemacht:

    typedef struct minterm
    {
        short int bit[MAX_VARIABLEN];
        short int verwendet;
        KOMPOSITION *komp_head;
        struct minterm *next;
    } MINTERM;
    

    ...oder steh' ich auf der Leitung?

    Greetz, Swordfish

    [edit] net war nicht gemeint [/edit]



  • @Swordfish: ich soll ja in c programmieren und nicht in c++.



  • Es gibt hier eine Struktur minterm

    struct minterm myTerm;
    

    Und einen typedef MINTERM

    MINTERM myTerm;
    

    Im Code steht (in der "Main Datei" oben)

    struct MINTERM myTerm;
    

    Ich programmiere in letzter Zeit nicht so viel ANSI C, aber meiner Meinung nach ist das struct dort mächtig fehl am Platze.



  • Swordfish schrieb:

    @net: Verarsch mich nicht... 🙄

    ich hab' doch gar nix geschrieben 😕



  • Bitte 1000-Mals um Entschuldigung. c.rackwitz war natürlich gemeint.

    Greetz, Swordfish



  • @ LordJaxom

    Danke. das struct war wirklich fehl am platze.
    Jetzt kommen keine warnungen 👍


Log in to reply