IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

probleme avec les headers


Sujet :

C++

  1. #1
    Membre averti
    Inscrit en
    Mars 2007
    Messages
    20
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 20
    Par défaut probleme avec les headers
    Bonjour,

    quand je compile mon programme il m'indique des erreurs dans les header
    et je ne comprend pas pourquoi.

    merci

  2. #2
    Rédacteur
    Avatar de Laurent Gomila
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Par défaut
    Ca doit être un bug du compilo, parce que je ne vois vraiment aucune erreur dans le code que tu nous montres...

  3. #3
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par Laurent Gomila
    Ca doit être un bug du compilo, parce que je ne vois vraiment aucune erreur dans le code que tu nous montres...
    la question d'origine a été modifiée, ou ya une touche d'ironie la dedans ?

  4. #4
    Rédacteur
    Avatar de Laurent Gomila
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Par défaut
    la question d'origine a été modifiée, ou ya une touche d'ironie la dedans ?
    Touche d'ironie bien sûr. D'habitude c'est plutôt "il manque un point-virgule à la ligne 24", mais là je voulais changer un peu.

  5. #5
    Membre averti
    Inscrit en
    Mars 2007
    Messages
    20
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 20
    Par défaut
    justement normalement je ne devrai pas toucher aux .h
    donc il ne devrai pas y avoir d'erreur

  6. #6
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par youss_kkk
    justement normalement je ne devrai pas toucher aux .h
    donc il ne devrai pas y avoir d'erreur
    donc c'est que l'erreur vient de ton code a toi :p

    on a des chances de voir un vrai message d'erreur ? ou tu nous laisse mariner encore un peu ?

  7. #7
    Rédacteur

    Avatar de millie
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    7 015
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 7 015
    Par défaut
    Il arrive parfois de voir des problèmes dans les headers de la bibliothèque standard lorsqu'on inclue des mauvais fichiers avant.

    Par exemple :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    //monfichier.hpp
    class Maclasse {
     
    } //oublie de ;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    //fichier cpp
    #include "monfichier.hpp"
    #include <iostream>
    ...
    Va indiquer des erreurs dans iostream.


    Avec mingw, certains fichiers peuvent également avoir des problèmes si on pousse les options (genre -pedantic, il aime pas trop en général)

  8. #8
    Membre averti
    Inscrit en
    Mars 2007
    Messages
    20
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 20
    Par défaut
    vla les erreurs

    Compiling...
    areu.cpp
    c:\program files\microsoft visual studio\vc98\include\traffic.h(130) : error C2146: syntax error : missing ';' before identifier 'AddressList'
    c:\program files\microsoft visual studio\vc98\include\traffic.h(130) : error C2501: 'NETWORK_ADDRESS_LIST' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\vc98\include\traffic.h(130) : error C2501: 'AddressList' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\vc98\include\traffic.h(264) : warning C4005: 'QOS_OBJECT_TRAFFIC_CLASS' : macro redefinition
    c:\program files\microsoft visual studio\vc98\include\qos.h(126) : see previous definition of 'QOS_OBJECT_TRAFFIC_CLASS'
    c:\program files\microsoft visual studio\vc98\include\traffic.h(294) : error C2011: '_QOS_TRAFFIC_CLASS' : 'struct' type redefinition
    c:\program files\microsoft visual studio\vc98\include\ntddndis.h(101) : error C2146: syntax error : missing ';' before identifier 'Offset'
    c:\program files\microsoft visual studio\vc98\include\ntddndis.h(101) : error C2501: 'ULONG_PTR' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\vc98\include\ntddndis.h(101) : error C2501: 'Offset' : missing storage-class or type specifiers
    G:\areu.cpp(547) : warning C4244: 'argument' : conversion from 'unsigned long' to 'unsigned short', possible loss of data
    Error executing cl.exe.

    areu.obj - 7 error(s), 2 warning(s)

  9. #9
    Invité
    Invité(e)
    Par défaut
    ah ben tu vois laurent, t'etais pas si loin... il manque un point-virgule a la ligne 130 ^^ mdr

    en tout cas, plus serieusement, il semblerait qu'un en-tete ai été oublié (#include manquant)

  10. #10
    Rédacteur

    Avatar de millie
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    7 015
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 7 015
    Par défaut
    Tu peux t'arrêter à la première :

    error C2146: syntax error : missing ';'
    Ca veut dire ce que ça veut dire

  11. #11
    Membre averti
    Inscrit en
    Mars 2007
    Messages
    20
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 20
    Par défaut
    voila le code

    // Call back function for traffic control. We are not using it, but required

    //for API call.

    #include<stdio.h>
    #include<Winsock2.h>
    #include<Traffic.h>
    #include<ntddndis.h>

    #pragma comment(lib, "ws2_32.lib")
    #pragma comment(lib, "Traffic.lib")

    void MyClNotifyHandler( HANDLE ClRegCtx,

    HANDLE ClIfcCtx,

    ULONG Event,

    HANDLE SubCode,

    ULONG BufSize,

    PVOID Buffer

    )

    {

    }

    int main(int argc, char *argv[])

    {

    DWORD destPort;

    PCHAR destAddress;

    if ( argc == 3)

    {

    destAddress = argv[1];

    destPort = atoi(argv[2]);

    }

    else

    {

    printf("Usage: %s destaddress destport", argv[0]);

    exit (-1);

    }

    // Intialization of Winsock API

    int err;

    WSADATA WSAData;

    // Startup Winsock

    err = WSAStartup(MAKEWORD(2,2), &WSAData);

    if (err)

    {

    printf("WSAStartup Failed (%d) Exiting\n", err);

    exit(err);

    }

    /* ================================================== */

    HANDLE ClientHandle;

    HANDLE IfcHandle;

    HANDLE flowHandle;

    HANDLE FilterHandle;

    // Initialize call back functions. We dont' need these, but is required for

    //TcRegisterClient API

    TCI_CLIENT_FUNC_LIST QoSFunctions;

    QoSFunctions.ClAddFlowCompleteHandler = NULL;

    QoSFunctions.ClDeleteFlowCompleteHandler = NULL;

    QoSFunctions.ClModifyFlowCompleteHandler = NULL;

    QoSFunctions.ClNotifyHandler = (TCI_NOTIFY_HANDLER)MyClNotifyHandler;

    // Register the client with Traffic control interface.

    long result = TcRegisterClient(CURRENT_TCI_VERSION, NULL,

    &QoSFunctions,&ClientHandle);

    if (result == NO_ERROR)

    {

    TC_IFC_DESCRIPTOR InterfaceBuffer[12];

    PTC_IFC_DESCRIPTOR pInterfaceBuffer = &InterfaceBuffer[0];

    ULONG BufferSize = 12 * sizeof(TC_IFC_DESCRIPTOR);

    // Find traffic control enabled interfaces on the cmachine

    result = TcEnumerateInterfaces(ClientHandle, &BufferSize,

    pInterfaceBuffer);

    if (result == NO_ERROR)

    {

    if (BufferSize == 0)

    {

    printf("no traffic control interfaces are available\n");

    }

    TCHAR interfaceName[500];

    // function maps a wide-character string to a new character string

    WideCharToMultiByte(CP_ACP, 0,

    InterfaceBuffer[0].pInterfaceName, -1,interfaceName, sizeof(interfaceName),

    0, 0 );

    // The TcOpenInterface function identifies and opens an interface based

    //on its text

    // string, which is available from a call to TcEnumerateInterfaces

    result = TcOpenInterface(interfaceName, ClientHandle, NULL, &IfcHandle);

    if (result == NO_ERROR)

    {

    // Creating of Traffic flow headers

    int curSize = sizeof (TC_GEN_FLOW )+ sizeof (QOS_DS_CLASS) +

    sizeof(QOS_OBJECT_HDR);

    char *bufFlow = new char[curSize];

    PTC_GEN_FLOW newFlow = (PTC_GEN_FLOW) bufFlow;

    // Create the new temp flow.

    LPQOS_OBJECT_HDR objHdr = NULL;

    //Set the Flow Spec

    newFlow->ReceivingFlowspec.DelayVariation = QOS_NOT_SPECIFIED;

    newFlow->ReceivingFlowspec.Latency = QOS_NOT_SPECIFIED;

    newFlow->ReceivingFlowspec.MaxSduSize = QOS_NOT_SPECIFIED;

    newFlow->ReceivingFlowspec.MinimumPolicedSize = QOS_NOT_SPECIFIED;

    newFlow->ReceivingFlowspec.PeakBandwidth = QOS_NOT_SPECIFIED;

    newFlow->ReceivingFlowspec.ServiceType = SERVICETYPE_GUARANTEED;//SERVICETYPE_CONTROLLEDLOAD;

    newFlow->ReceivingFlowspec.TokenBucketSize = QOS_NOT_SPECIFIED;

    newFlow->ReceivingFlowspec.TokenRate = QOS_NOT_SPECIFIED;


    newFlow->SendingFlowspec.DelayVariation = QOS_NOT_SPECIFIED;

    newFlow->SendingFlowspec.Latency = QOS_NOT_SPECIFIED;

    newFlow->SendingFlowspec.MaxSduSize = QOS_NOT_SPECIFIED;

    newFlow->SendingFlowspec.MinimumPolicedSize = QOS_NOT_SPECIFIED;

    newFlow->SendingFlowspec.PeakBandwidth = QOS_NOT_SPECIFIED;

    newFlow->SendingFlowspec.ServiceType = SERVICETYPE_GUARANTEED;//SERVICETYPE_CONTROLLEDLOAD;

    newFlow->SendingFlowspec.TokenBucketSize = QOS_NOT_SPECIFIED;

    newFlow->SendingFlowspec.TokenRate = QOS_NOT_SPECIFIED;

    newFlow->TcObjectsLength = sizeof QOS_DS_CLASS + sizeof QOS_OBJECT_HDR;


    /**************** Set DSCP.**************************/

    LPQOS_DS_CLASS pQOSClass = (LPQOS_DS_CLASS)(&(newFlow->TcObjects[0]));

    pQOSClass->ObjectHdr.ObjectType = QOS_OBJECT_DS_CLASS;

    pQOSClass->ObjectHdr.ObjectLength = sizeof QOS_DS_CLASS;

    pQOSClass->DSField = 0x2E;

    objHdr = (LPQOS_OBJECT_HDR)((char *)&(newFlow->TcObjects[0]) + sizeof(QOS_DS_CLASS));


    // Set the end of the list

    objHdr->ObjectType = QOS_OBJECT_END_OF_LIST;

    objHdr->ObjectLength = sizeof QOS_OBJECT_HDR;

    // adds a new flow on the specified interface. The flow is like a channel,

    // that determines how to shape the traffic if it tunnelled through it.

    int retCode = TcAddFlow(IfcHandle, NULL, 0, newFlow, &flowHandle);

    // Create a filter. All traffic matching the filter will pass through the flow

    TC_GEN_FILTER GenericFilter;

    IP_PATTERN Pattern, Mask;

    memset(&Pattern,0,sizeof(IP_PATTERN));

    memset(&Mask,0,sizeof(IP_PATTERN));

    GenericFilter.AddressType = NDIS_PROTOCOL_ID_TCP_IP; // Protocol stack is TCP/IP

    GenericFilter.PatternSize = sizeof(IP_PATTERN);

    GenericFilter.Pattern = &Pattern; // pattern to match, defined below

    GenericFilter.Mask = &Mask;

    // Filter pattern. This is where you can tweak the flow filter parameters

    // configured to match on all outgoing UDP packets.

    Pattern.Reserved1 = 0;

    Pattern.Reserved2 = 0;

    Pattern.SrcAddr = 0; //IP_ADDRESS;

    Pattern.DstAddr = 0; //IP_ADDRESS;

    Pattern.tcSrcPort = 80;

    Pattern.tcDstPort = 80;

    Pattern.ProtocolId = IPPROTO_UDP;

    Pattern.Reserved3[0] = 0;

    Pattern.Reserved3[1] = 0;

    Pattern.Reserved3[2] = 0;

    // Patterns mask

    Mask.Reserved1 = 0;

    Mask.Reserved2 = 0;

    Mask.SrcAddr = 0; //0xFFFFFFFF;

    Mask.DstAddr = 0; //0xFFFFFFFF;

    Mask.tcSrcPort = 0; //0xFFFF;

    Mask.tcDstPort = 0xFFFF;

    Mask.ProtocolId = 0xFF;

    Mask.Reserved3[0] = 0;

    Mask.Reserved3[1] = 0;

    Mask.Reserved3[2] = 0;

    // Add filter to the flow. This point onwards all traffic matching the

    //filter, will pass through the flow.


    retCode = TcAddFilter(flowHandle, &GenericFilter, &FilterHandle);

    /*if(retCode != NO_ERROR)

    {

    switch(retCode)

    {

    case ERROR_SIGNAL_PENDING:

    printf("The function is being executed asynchronously; the client will

    be called back through the client-exposed ClAddFlowComplete function when

    the flow has been added or when the process has been completed.\n");

    break;

    case ERROR_INVALID_HANDLE:

    printf("The interface handle is invalid.\n");

    break;

    case ERROR_NOT_ENOUGH_MEMORY:

    printf("The system is out of memory.\n");

    break;

    case ERROR_INVALID_PARAMETER:

    printf("A parameter is invalid.\n");

    break;

    case ERROR_INVALID_SERVICE_TYPE:

    printf("An unspecified or bad INTSERV service type has been

    provided.\n");

    break;

    case ERROR_INVALID_TOKEN_RATE:

    printf("An unspecified or bad TOKENRATE value has been provided.\n");

    break;

    case ERROR_INVALID_PEAK_RATE:

    printf("The PEAKBANDWIDTH value is invalid.\n");

    break;

    case ERROR_INVALID_SD_MODE:

    printf("The SHAPEDISCARDMODE is invalid.\n");

    break;

    case ERROR_INVALID_QOS_PRIORITY:

    printf("The priority value is invalid.\n");

    break;

    case ERROR_INVALID_TRAFFIC_CLASS:

    printf("The traffic class value is invalid.\n");

    break;

    case ERROR_NO_SYSTEM_RESOURCES:

    printf("There are not enough resources to accommodate the requested

    flow.\n");

    break;

    case ERROR_TC_OBJECT_LENGTH_INVALID:

    printf("Bad length specified for the TC objects.\n");

    break;

    case ERROR_INVALID_DIFFSERV_FLOW:

    printf("Applies to Diffserv flows. Indicates that the QOS_DIFFSERV

    object was passed with an invalid parameter.\n");

    break;

    case ERROR_DS_MAPPING_EXISTS:

    printf("Applies to Diffserv flows. Indicates that the

    QOS_DIFFSERV_RULE specified in TC_GEN_FLOW already applies to an existing

    flow on the interface.\n");

    break;

    case ERROR_INVALID_SHAPE_RATE:

    printf("The QOS_SHAPING_RATE object was passed with an invalid

    ShapeRate.\n");

    break;

    case ERROR_INVALID_DS_CLASS:

    printf("The QOS_DS_CLASS is invalid.\n");

    break;

    case ERROR_NETWORK_UNREACHABLE:

    printf("The network cable is not plugged into the adapter.\n");

    break;

    }

    printf("TcAddFlow: ERROR: %lu\n",retCode);

    // printf("Handle was %d\n", (int)IfcHandle);

    return -1;

    } */

    //check flows

    //EnumFlows(IfcHandle);

    }

    else

    {

    printf("TcOpenInterface returned 0x%x\n", result);

    return -1;

    }

    }

    /*else

    {

    switch(result)

    {

    case NO_ERROR:

    printf("The function executed without errors.\n");

    break;

    case ERROR_INVALID_HANDLE:

    printf("The client handle is invalid.\n");

    break;

    case ERROR_INVALID_PARAMETER:

    printf("One of the parameters is NULL.\n");

    break;

    case ERROR_INSUFFICIENT_BUFFER:

    printf("The buffer is too small to enumerate all interfaces. If this

    error is returned, the correct (required) size of the buffer is passed back

    in pBufferSize.\n");

    printf("Size required: %d\n", BufferSize);

    break;

    case ERROR_NOT_ENOUGH_MEMORY:

    printf("The system is out of memory.\n");

    break;

    }

    printf("TcEnumerateInterfaces returned 0x%x\n", result);

    return -1;

    } */

    }

    else

    {

    printf("TcRegisterClient returned 0x%x\n", result);

    return -1;

    }

    // Create a normal UDP socket for sending data

    SOCKET sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

    if (sd == INVALID_SOCKET)

    {

    err = GetLastError();

    printf("\"Socket\" failed with error %d\n", err);

    return 1;

    }

    SOCKADDR_IN destAddr;

    memset (&destAddr, 0, sizeof(SOCKADDR_IN));

    destAddr.sin_family = AF_INET;

    destAddr.sin_port = htons(destPort);

    destAddr.sin_addr.s_addr = inet_addr(destAddress); // this is our test destination IP

    char buf[1000];

    int nRet;

    nRet = sendto( sd, buf, 1000, 0, (sockaddr*)&destAddr,sizeof(SOCKADDR_IN));

    // nRet should have the number of bytes successfully sent.

    //char buff[1000];

    //scanf("%s",buff);

    // CLEANUP

    result = TcDeleteFilter(FilterHandle);

    if (result != NO_ERROR)

    {

    printf("Error deleting filter\n");

    }

    // Delete flow associated with the network interface

    result = TcDeleteFlow(flowHandle);

    if (result != NO_ERROR)

    {

    printf("Error deleting flow\n");

    }

    // Close the Traffic control interface opened earlier.

    result = TcCloseInterface(IfcHandle);

    /*if (result != NO_ERROR)

    {

    switch(result)

    {

    case ERROR_INVALID_HANDLE:

    printf("The interface handle is invalid.\n");

    break;

    case ERROR_TC_SUPPORTED_OBJECTS_EXIST:

    printf("Not all flows have been deleted for this interface.");

    }

    printf("Error closing interface\n");

    } */

    // Unregister the client.

    result = TcDeregisterClient(ClientHandle);

    /*if (result != NO_ERROR)

    {

    switch(result)

    {

    case ERROR_INVALID_HANDLE:

    printf("Invalid interface handle, or the handle was set to NULL.\n");

    break;

    case ERROR_TC_SUPPORTED_OBJECTS_EXIST:

    printf("Interfaces are still open for this client. all interfaces must be closed to deregister a client.\n");

    }

    printf("Error degresitering client\n");

    } */

    // shutdown the socket

    shutdown(sd, SD_BOTH);

    closesocket(sd);

    WSACleanup();

    return 0;

    }

  12. #12
    Rédacteur

    Avatar de millie
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    7 015
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2006
    Messages : 7 015
    Par défaut
    Le compilateur indiquait un problème dans le header, pourquoi tu copie colle le fichier cpp ?

    Et merci d'utiliser la balise


  13. #13
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par millie
    Le compilateur indiquait un problème dans le header, pourquoi tu copie colle le fichier cpp ?

    Et merci d'utiliser la balise :code:
    moi des questions comme ca, ya un moment ou je quitte en refermant la porte derriere moi... il ne veut manifestement pas chercher un peu par lui meme... dommage

  14. #14
    Membre averti
    Inscrit en
    Mars 2007
    Messages
    20
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 20
    Par défaut
    les headers ils sont bon je les ai pas toucher
    le probleme vien pas de la
    quand je les utilise ailleur ya po de pb

  15. #15
    Rédacteur
    Avatar de Laurent Gomila
    Profil pro
    Développeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Par défaut
    Est-ce que tu pourrais s'il te plaît :
    - Faire un effort d'orthographe
    - Avoir l'amabilité d'ajouter les balises CODE lorsqu'on te le signale (tu peux éditer ton message précédent...)

    Si tu ajoutes #include <windows.h> entre <Winsock2.h> et <Traffic.h> ça donne quoi ?

Discussions similaires

  1. Help!! Probleme avec les dates sur SQL SERVER
    Par Nadaa dans le forum MS SQL Server
    Réponses: 16
    Dernier message: 03/08/2006, 16h55
  2. Problemes avec les header informations
    Par BernardT dans le forum Langage
    Réponses: 1
    Dernier message: 15/11/2005, 13h10
  3. PROBLEME AVEC LES REQUETES IS NULL / NOT EXISTS
    Par sylvaine dans le forum Langage SQL
    Réponses: 5
    Dernier message: 04/06/2004, 13h26
  4. Problem avec les *.AVI sur les panels
    Par NaDiA_SoFt dans le forum C++Builder
    Réponses: 3
    Dernier message: 31/08/2003, 22h50
  5. probleme avec les processus
    Par saidi dans le forum Autres éditeurs
    Réponses: 1
    Dernier message: 05/02/2003, 00h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo