Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2004
    Messaggi
    229

    [C]: problema di accesso a struttura

    ciao a tutti

    ho il seguente problema nell'accedere alla struttura proc_state sotto definita:

    codice:
    typedef unsigned int U32;
    
    typedef struct {
    	U32 entry_hi;
    	U32 cause;
    	U32 status;
    	U32 pc_epc;  /* pc in the new area, epc in the old area */
    	U32 gpr[31];
    	U32 hi;
    	U32 lo;				
    } state_t;
    
    typedef struct tcb_t {   		       	/* thread control block */
            tid_t           tid;            	/* thread identifier */
            status_t        status; 		/* thread's status */
    	struct state_t  *proc_state;		/* processor state */
    } tcb_t;
    
    #define reg_a0  gpr[3]
    
    unsigned int cause;
    tcb_t *CurrentThread;
    cause=CurrentThread.proc_state.reg_a0;  //anche cause=CurrentThread->proc_state.reg_a0; da lo stesso errore
    mi da il seguente errore:

    exceptions.c:53: error: request for member `proc_state' in something not a structure or union


    qualcuno sa dove sbaglio????

    grazie in anticipo


    Ad Maiora

  2. #2
    Utente di HTML.it L'avatar di andbin
    Registrato dal
    Jan 2006
    residenza
    Italy
    Messaggi
    18,284

    Re: [C]: problema di accesso a struttura

    Originariamente inviato da robboso
    tcb_t *CurrentThread;
    cause=CurrentThread.proc_state.reg_a0; //anche cause=CurrentThread->proc_state.reg_a0; da lo stesso errore
    cause=CurrentThread->proc_state->reg_a0;
    Andrea, andbin.devSenior Java developerSCJP 5 (91%) • SCWCD 5 (94%)
    java.util.function Interfaces Cheat SheetJava Versions Cheat Sheet

  3. #3
    A parte il fatto CurrentThread e proc_state vengono utilizzate anche se non c'è nessuna zona di memoria a cui puntano.

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2008
    Messaggi
    1,326
    codice:
    typedef struct tcb_t {   		       	/* thread control block */
            tid_t           tid;            	/* thread identifier */
            status_t        status; 		/* thread's status */
    	struct state_t  *proc_state;		/* processor state */
    } tcb_t;
    Scusa non ho letto benissimo tutto il codice ma struct state_t è un tipo inesistente: tu hai dichiarato una struct e tramite typedef l'hai chiamata "state_t" ma non esiste il tipo struct state_t perché quando hai dichiarato quella struct hai scritto direttamente

    tupedef struct{
    ...
    ...
    } state_t;

    quindi state_t è il tipo stuttura, non struct state_t.

    modifca quindi quella riga in rosso con

    codice:
    state_t  *proc_state;
    forse è per quello che ti dice che proc_state non è una struttura... l'hai dichiarata di un tipo che non esiste in realtà

    Ovviamente fai caso anche ai consigli che ti hanno dato gli altri che non ho letto con attenzione (comunque gli operatori -> al posto di . credo siano necessari perché usi puntatori a struct)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.