1

libxl ライブラリを使用して xls ファイルをエクスポートする機能を備えたプログラムがあります。私のメインでは、関数を呼び出しません。関数がコメント化されている場合、エクスポート関数が実装されているcppでは、プログラムは適切に実行され、コンソールにいくつかのものが出力されます。コメントの下から関数を取り出すと、プログラムはアウトなしですぐに終了しますエラーが発生します。デバッグを使用しようとするたびに、このエラーが発生します

C:Documents and SettingsplatonasWorkspace Eclipse for CHeliostatValidationsrcHeliostatValidation.cpp

どちらであるべきか

C:/HeliostatValidation/src/HeliostatValidation.cpp

私の基本的な質問は、関数を呼び出さないので、関数が使用されていないためにエラーが発生する理由です。

main.cpp

#include <iostream>
using namespace std;
#include "ValidationController.h"
#include "SettingsHandler.h"


int main() {
SettingsHandler shObj;
shObj.readFile();
shObj.setVariables();
shObj.printSettings();
ValidationController vcObj;

vcObj.calcContrBatch(2013,9,26,8,47,47,Sun::OneYear,Sun::ArcsinMode,Sun::East);


vcObj.printData(vcObj.dataValues);
//  vcObj.exportData(vcObj.dataValues,"file");

return 0;
}

および機能を持つcpp

#include <iostream>
using namespace std;
#include "ValidationController.h"
#include <array>
#include "NTP.h"
#include "DayNumber.h"
#include "Heliostat.h"
#include "Data.h"
#include <vector>
#include <fstream>
#include <iomanip>
#include "libxl.h"
using namespace libxl;

 void ValidationController::exportData(const vector<Data>& dataVector,string nameOfFile) {

    Book *book = xlCreateBook();
    if(book){
        Sheet *sheet=book->addSheet("Sheet1");
        if(sheet){
            sheet->writeStr(2,2,"Year");
            sheet->writeStr(2,3,"Month");
            sheet->writeStr(2,4,"Day");
            sheet->writeStr(2,5,"DayOfWeek");
            sheet->writeStr(2,6,"LctHour");
            sheet->writeStr(2,7,"Minutes");
            sheet->writeStr(2,8,"Seconds");
            sheet->writeStr(2,9,"TimeDec");
            sheet->writeStr(2,10,"Sun's Elevation");
            sheet->writeStr(2,11,"Sun's Azimuth");
            sheet->writeStr(2,12,"Helio's Pitch");
            sheet->writeStr(2,13,"Helio's Azimuth");

//          int lineMorphing=dataVector.at(0).getDayOfWeek();
//
//          for (unsigned int i=0,m=3;i<dataVector.size();i++,m++){
//              if(dataVector.at(i).getDayOfWeek()!=lineMorphing){
//                  lineMorphing=dataVector.at(i).getDayOfWeek();
//                  m++;
//              }
//              int k=0;
//              sheet->writeNum(m,++k,dataVector.at(i).getYear());
//              sheet->writeNum(m,++k,dataVector.at(i).getMonth());
//              sheet->writeNum(m,++k,dataVector.at(i).getDay());
//              sheet->writeNum(m,++k,dataVector.at(i).getDayOfWeek());
//              sheet->writeNum(m,++k,dataVector.at(i).getHour());
//              sheet->writeNum(m,++k,dataVector.at(i).getMinutes());
//              sheet->writeNum(m,++k,dataVector.at(i).getSeconds());
//              sheet->writeNum(m,++k,dataVector.at(i).getTimeInDecimal());
//              sheet->writeNum(m,++k,dataVector.at(i).getSunsPitch());
//              sheet->writeNum(m,++k,dataVector.at(i).getSunsAzimuth());
//              sheet->writeNum(m,++k,dataVector.at(i).getHelioPitch());
//              sheet->writeNum(m,++k,dataVector.at(i).getHelioAzimuth());
//
//          }
//
        }
        nameOfFile.append(".xls");
        const char* fileName=nameOfFile.c_str();
        book->save(fileName);
        book->release();

    }else{
        cout <<"error on book"<<endl;
    }
}

「sheet1」のようなすべての文字列の前に L があることに気付きました

Sheet *sheet=book->addSheet(L"Sheet1");

公式の例では、ライブラリについては、プロパティに移動しました->ビルドC / C ++->設定->リンカーMinGW(タブで)-->ライブラリとパスと名前を追加しましたエクステンションなしのライブラリ.lib また、libxl ファイルの「include cpp」という名前のフォルダーのパスをコンパイラ インクルードに含めて、プログラムがヘッダーを表示できるようにしました。

メインで呼び出されていない関数がプログラムを終了させる責任があるのはなぜですか?

4

0 に答える 0