2015-10-22 4 views
0

Я пишу программу, но получаю это предупреждение! Может кто-то мне помочь в этом отношении.Неявная декларация Функция «setWeight»

#include <stdio.h> 
#include <stdlib.h> 

typedef int bool; 
#define true 1 
#define false 0 


#define M 5     // Define total molecules 
#define MAX 31    // used to Create a range 
#define N 6    // Define total nodes in the given graph 


unsigned int nondet_uint(); // returns a non_deterministic uint 

typedef unsigned __CPROVER_bitvector[M] bitvector; 

//constrains the non_detrministic uint to be between 0 and n 
unsigned int oneTon (unsigned int n){ 
unsigned int result = nondet_uint(); 
    __CPROVER_assume(result>=1 && result<=n); 
     return result; 
}; 

//Constrain the value between 0 and 1 
unsigned int nondet(){ 
unsigned int num = nondet_uint(); 
__CPROVER_assume(num>= 0 && num <= 1); 
return num; 
}; 


//Define a structure to represent the EdgeBag that is a tuple : 
// edgeBag := (i,j,edgeWeight, mask, inclusionSet, exclusionSet) 
struct EdgeBag 
{ 
    int ith; 
    int jth; 
    bitvector edgeWeight; 
    bitvector mask; 
    bitvector inclusionSet; 
    bitvector exclusionSet; 
}; 


// Setweight function 
// Going to give the edges the weight and then allow furture calculation of inclusion and exclusion set 

bitvector setWeight(bitvector node) { 
    bitvector edge; 
    edge = 00000; 
    for(unsigned int k=0; k<N; k++){ 
     if ((node & (00001 << k)) == (00001 << k)) { 
       edge = (edge | (nondet() << k)); 
      } 
    } 
    printf("value of the egde is %d", edge); 
    return edge; 
} 

void main(){ 

unsigned int pos , i, j, k, l, v, w, x, y , iVal, jVal; 
unsigned int edgePos, bagNo = 0, colorNode = 0 , minColor, len = 0, cPos = 0; 
bool C0 , C1 , C2 , C3; 

bitvector compartment1 , compartment2 , compartment3 , compartment4, compartment5, compartment6; 
bitvector nodes[N] = {compartment1, compartment2, compartment3, compartment4, compartment5, compartment6}; 
bitvector total , fareTotal, outTotal, inTotal; 


// Represent the graph with given topology 
bool graph[N][N] = {{0, 0, 1, 1, 0, 0 }, 
        {1, 0, 0, 0, 0, 0}, 
        {0, 1, 0, 0, 0, 0}, 
        {0, 0, 1, 0, 1, 0}, 
        {0, 0, 0, 0, 0, 1}, 
        {0, 1, 0, 0, 0, 0} 
    }; 


// Specify that all compartments are distinct 
    for(i=0; i<N; i++) { 
     for(j=0 ; j < N ; j++) { 
      if(graph[i][j] == 1) { 
       len = len + 1; 
      } 
      if(i != j) { 
       __CPROVER_assume(nodes[i] != nodes[j]); 
      } 
     } 
    } 

// Create a structure that will contain edges. 
    struct EdgeBag edgeBag[len]; 

// Define colorGraph and colorSet for the represetaion 
    bool colorGraph[len][len]; 
    unsigned int colorSet[len]; 


// Set the weight of the edge : for each edge in the graph call add to the esdge bag and add its edgeweight 
// setWeight function and allow all possible subsets to move from a node to anotheer 
// Set ith jth position and edgeweight to the position of edgeBag[len] array 
edgePos = 0; 
for(i=0; i<N; i++) { 
    for(j=0; j<N; j++) { 
      if (graph[i][j] == 1) { 
       edgeBag[edgePos].ith = i; 
       edgeBag[edgePos].jth = j; 

      **HERE IS THE PROBLEM !!!** 
       edgeBag[edgePos].edgeWeight = setWeight(nodes[i]); 

       edgePos = edgePos + 1; 
      } 
    } 
} 

Я понимаю, что это предупреждение возникает, когда компилятор не видел заявление перед использованием функции. Но я уже объявлял функцию setWeight и выглядел так, как будто тип тоже соответствует. Пожалуйста, помогите мне с этим, я застрял здесь с прошлой ночи. Благодаря

+2

Похоже, что 'setWeight' принимает аргумент' bitvector', но вы передаете ему массив 'bitvector' –

+0

Спасибо, johnny, но это была ошибка редактирования. Это нормально? – user2754673

ответ

1

вы действуете ожидает bitvector - bitvector setWeight(bitvector node)

но получает bitvector [] -

bitvector nodes[N] = {...};

...

[edgePos].edgeWeight = setWeight(nodes);

+0

Извините, что отредактировал его и пропустил вызов (узлы [i]) в качестве аргумента – user2754673

+3

скопируйте-вставьте свой код и не переписывайте его –

+0

Теперь я прохожу (узлы битвектора [i]), который является битВектор, который ожидает функция. Теперь проблема? – user2754673

Смежные вопросы