Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    116

    [C] dimesione array dentro un typedef

    Ciao a tutti,
    ho questo problema e non riesco a venirne fuori.
    Voglio definire la dimensione di un array dentro una typedef. L´array é un array di una struct definita in precedenza (struct _priv_state_biquad).
    Ho scritto all´inizio del programma #define max_N 10; (ho provato anche con
    static const int max_N = 10, ma il programma dá errore alla riga dove uso la variabile max_N (ovvero state_biquad F_array[max_N]

    Ecco il codice:

    #define max_N 10;


    typedef struct _priv_state_biquad{
    float w_nm1; //w(n-1)
    float w_nm2; //w(n-2)
    }state_biquad;



    typedef struct{

    struct _priv_friction{
    int N ;/**< Number of zeros and poles. NOTE: N Must be a multiple of 2 and greater than 0*/
    float h ;/**< Density of the poles per frequency decads*/
    state_biquad F_array[max_N];

    } priv; /**< Instance of the substructure */

    } t_friction_interactor;
    ---------------------------------------------------------------
    Libera il mondo: usa linux!

    Neither MS-Word nor MS-PowerPoint attachments please: http://www.gnu.org/philosophy/no-word-attachments.html

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2008
    Messaggi
    1,326
    Rimuovi il ; dopo la #define. Le direttive al precompilatore non vanno terminate con ;
    In pratica in quel modo stai definendo max_N non come 10, ma come 10; che è un'istruzione e non una costante (ovviamente un'istruzione senza alcun effetto).
    every day above ground is a good one

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    116
    GRAZIE.

    Non me ne ero accorto
    ---------------------------------------------------------------
    Libera il mondo: usa linux!

    Neither MS-Word nor MS-PowerPoint attachments please: http://www.gnu.org/philosophy/no-word-attachments.html

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 © 2024 vBulletin Solutions, Inc. All rights reserved.