Setenv:在初始化程序中将类型表达式列表视为复合表达式

时间:2015-04-06 05:55:01

标签: c++ setenv

获取Type expression list treated as compound expression in initializer 在这两个函数调用 -

    char itoa(new_total, new_total_ch, 10);
    int setenv("COUNT_TOTAL", new_total_ch, 1);

这是代码段 -

#include <iostream>
// create process team
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <ctime>
// initialize & process
#include <time.h>
#include <string>
#include <fstream>
#include <cmath>
#include <iosfwd>
// initialize & process
using std::ifstream;
using namespace std;

class Count3sProcessParallel {

public:
    //int process();
    int pr_count;
    int process();
    typedef int COUNT_TOTAL;


private:

    int worker;
    //declare process()
    long unit_of_work;
    long lower_bound;
    long upper_bound;
    int pr_i;
    char * ct;
    int ct_i;
    int new_total;
    char itoa();
    char * new_total_ch;
    int setenv();

};


int Count3sProcessParallel::process() {
    // determine upper lower bounds
    unit_of_work = in_length/workers_num;
    lower_bound = (worker -1) * unit_of_work;
    upper_bound = (worker * unit_of_work) -1;

    // iterate and count
    pr_count = 0;
    for (pr_i = lower_bound; pr_i < upper_bound; pr_i++)
      if (floor(in_buffer[pr_i] == 3))
        pr_count++;
        return pr_count;

    //update COUNT_TOTAL
    ct = getenv("COUNT_TOTAL");
    ct_i = atoi(ct);
    new_total = (pr_count + ct_i);
    char * new_total_ch[33];
    char itoa(new_total, new_total_ch, 10);
    int setenv("COUNT_TOTAL", new_total_ch, 1);

    delete[] in_buffer;
    return 0;
}

我该如何解决这个问题?感谢。

1 个答案:

答案 0 :(得分:1)

删除主要类型。只需使用:

itoa(new_total, new_total_ch, 10);
setenv("COUNT_TOTAL", new_total_ch, 1);