Thread: Saving in binary

  1. #1
    Registered User
    Join Date
    Feb 2005

    Saving in binary

    I am trying to save some variables to a .txt file...
    I get strange linker errors when I try to write or read these files.

    My headers...

    #include <iostream>
    #include <fstream>
    #include <string>
    #include <cstring>
    using namespace std;
    Inializing the structures
    struct Variables
     int distOnOff;
     int distDrive;
     int distClip;
     int distOverdrive;
     int distAfterwah;
     int distSatOnOff;
     int distSaturation;
     int distLpFilter;
     int distLpFilterQ;
     int distBoostOnOff;
     int distBoostHz;
     int distBoostDb;
    #pragma pack(push, 1)
    struct FileData
       int var_int;
       char var_string[13];
       Variables var_struct;
    #pragma pack(pop)
    initializing the functions performing the serializtion
    bool ReadSerialized(const char * filename, const FileData & data);
    bool WriteSerialized(const char * filename, FileData & data);
    My function calling the serialization
    void CFXBOXDlg::ClickBadd()
    // TODO: Add your message handler code here
    FileData data_out;
    data_out.var_struct.distOnOff = m_distOnOff;
    data_out.var_struct.distDrive = m_distDrive;
    data_out.var_struct.distClip = m_distClip;
    data_out.var_struct.distOverdrive = m_distOverdrive;
    data_out.var_struct.distAfterwah = m_distAfterwah;
    data_out.var_struct.distSatOnOff = m_distSatOnOff;
    data_out.var_struct.distSaturation = m_distSaturation;
    data_out.var_struct.distLpFilter = m_distLpFilter;
    data_out.var_struct.distLpFilterQ = m_distLpFilterQ;
    data_out.var_struct.distBoostOnOff = m_distBoostOnOff;
    data_out.var_struct.distBoostHz = m_distBoostHz;
    data_out.var_struct.distBoostDb = m_distBoostDb;
    WriteSerialized("Presets.txt", data_out);
    FileData data_in;
    ReadSerialized("Presets.txt", data_in);
    m_distOnOff = (int)data_in.var_struct.distOnOff;
    m_distDrive = (int)data_in.var_struct.distDrive;
    m_distClip = (int)data_in.var_struct.distClip;
    m_distOverdrive = (int)data_in.var_struct.distOverdrive;
    m_distAfterwah = (int)data_in.var_struct.distAfterwah;
    m_distSatOnOff = (int)data_in.var_struct.distSatOnOff;
    m_distSaturation = (int)data_in.var_struct.distSaturation;
    m_distLpFilter = (int)data_in.var_struct.distLpFilter;
    m_distLpFilterQ = (int)data_in.var_struct.distLpFilterQ;
    m_distBoostOnOff = (int)data_in.var_struct.distBoostOnOff;
    m_distBoostHz = (int)data_in.var_struct.distBoostHz;
    m_distBoostDb = (int)data_out.var_struct.distBoostDb;
    m_presetStr = "";
    My errors (one for each) ->WriteSerialized("Presets.txt", data_out);
    ->ReadSerialized("Presets.txt", data_in);

    FXBOX error LNK2019: unresolved external symbol "protected: bool __thiscall CFXBOXDlg::ReadSerialized(char const *,struct FileData const &)" (?ReadSerialized@CFXBOXDlg@@IAE_NPBDABUFileData@@@Z) referenced in function "protected: void __thiscall CFXBOXDlg::ClickBadd(void)" (?ClickBadd@CFXBOXDlg@@IAEXXZ)
    FXBOX error LNK2019: unresolved external symbol "protected: bool __thiscall CFXBOXDlg::WriteSerialized(char const *,struct FileData &)" (?WriteSerialized@CFXBOXDlg@@IAE_NPBDAAUFileData@@@Z) referenced in function "protected: void __thiscall CFXBOXDlg::ClickBadd(void)" (?ClickBadd@CFXBOXDlg@@IAEXXZ)

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    >initializing the functions performing the serializtion
    You declare them, but you don't define them. The linker is complaining that neither of these functions has an executable body anywhere.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Saving linked lists to a binary file
    By kotoko in forum C Programming
    Replies: 1
    Last Post: 06-14-2008, 06:41 PM
  2. Replies: 4
    Last Post: 03-19-2005, 04:21 PM
  3. saving a binary tree??
    By fayte in forum C++ Programming
    Replies: 9
    Last Post: 01-27-2005, 01:32 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM