running example

90 views
Skip to first unread message

Daniel Cegiełka

unread,
Jul 1, 2011, 7:36:38 PM7/1/11
to high-frequency-fix-support
Hi, 
I try to run the example from the documentation, but I get errors.


#include <iostream>
#include <string>

#define HFFIX_NO_BOOST_DATETIME

#include "hffix.hpp"

int main()
{
char buffer[512];

hffix::message_writer writer(buffer, buffer + 512);

writer.push_back_header();
writer.push_back_string(hffix::tag::MsgType, "0");
writer.push_back_string(hffix::tag::SenderCompID, "AAAA");
writer.push_back_string(hffix::tag::TargetCompID, "BBBB");
writer.push_back_int(hffix::tag::MsgSeqNum, 1);
//writer.push_back_timestamp(hffix::tag::SendingTime, boost::posix_time::microsec_clock::universal_time());
writer.push_back_trailer();

std::cout.write(writer.message_begin(), writer.message_size()) << std::endl;
std::cout << "Wrote " << writer.message_size() << " bytes to buffer." << std::endl;

return 0;
}



c:\tmp\hffix>g++ t.cc -o t
In file included from t.cc:6:0:
hffix.hpp:1560:9: error: a class-key must be used when declaring a friend
hffix.hpp:1560:9: error: friend declaration does not name a class or function
hffix.hpp: In member function 'const hffix::message_reader::const_iterator& hffix::message_reader::begin() const':
hffix.hpp:1414:35: error: 'logic_error' is not a member of 'std'
hffix.hpp: In member function 'const hffix::message_reader::const_iterator& hffix::message_reader::end() const':
hffix.hpp:1424:35: error: 'logic_error' is not a member of 'std'
hffix.hpp: In member function 'const hffix::message_reader::const_iterator& hffix::message_reader::message_type() const':
hffix.hpp:1434:35: error: 'logic_error' is not a member of 'std'
hffix.hpp: In member function 'const hffix::message_reader::const_iterator& hffix::message_reader::check_sum() const':
hffix.hpp:1444:35: error: 'logic_error' is not a member of 'std'
hffix.hpp: In member function 'const char* hffix::message_reader::message_end() const':
hffix.hpp:1486:35: error: 'logic_error' is not a member of 'std'
hffix.hpp: In member function 'size_t hffix::message_reader::message_size() const':
hffix.hpp:1496:35: error: 'logic_error' is not a member of 'std'
hffix.hpp: In member function 'void hffix::message_reader_const_iterator::increment()':
hffix.hpp:1641:24: error: 'hffix::message_reader::const_iterator hffix::message_reader::end_' is private
hffix.hpp:1693:57: error: within this context
hffix.hpp:1646:14: error: 'void hffix::message_reader::malformed()' is private
hffix.hpp:1695:43: error: within this context
hffix.hpp: At global scope:
hffix.hpp:3186:1: error: global qualification of class name is invalid before '{' token


I use g++ under windows.

c:\tmp\hffix>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/opt/mingw32/bin/../libexec/gcc/mingw32/4.5.1/lto-wrapper.exe
Target: mingw32
Configured with: ../../src/gcc-4.5.1/configure --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,obj-c++ --enable-threads=win32 --enable-libgomp --enable
-lto --enable-fully-dynamic-string --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-nls --disable-win32-registry --disable-symvers --pre
fix=/mingw --disable-werror --enable-cxx-flags='-fno-function-sections -fno-data-sections' --with-pkgversion=tdm-1 --enable-sjlj-exceptions --with-bugurl=http://
Thread model: win32
gcc version 4.5.1 (tdm-1)


best regards,
daniel

JDB

unread,
Jul 8, 2011, 10:03:31 AM7/8/11
to high-frequency-fix-support
Hi Daniel,

Sorry for the delay in responding, I've been on holiday.

I just released a new HFFIX version 1.4 which should solve your
compile errors.

Thanks for the bug report!

danice

unread,
Jul 24, 2011, 4:33:24 PM7/24/11
to high-frequency-fix-support
I fixed this error now - you need to add:

# include <stdexcept>

on Linux is also a different error (g++) but to fix it, enough to add:

# include <cstddef>

btw. On linux it doesn't print the separator (SOH with
std:cout.write()). Is this a bug?

best regards,
daniel

JDB

unread,
Jul 24, 2011, 11:12:31 PM7/24/11
to high-frequency-fix-support
Hi Daniel,

Thanks for the bug report! I probably forgot to include <stdexcept> in
hffix.hpp because I was including it from somewhere else, I'll look
into that.

hffix::message_writer writes the SOH characters that FIX 4.2 uses to
delimit fields, is that what you're talking about? Could you be more
specific?

Oh, I think I know what you mean: if you try to print an SOH character
to the terminal in Linux, then nothing will appear. That's just
because the terminal doesn't render the SOH character. The
hffix::message_writer is writing the SOH characters to the buffer that
you supply, but if you want to see the non-printing characters in that
buffer, you'll have to look at it some way other than sending it
straight to the terminal.

You could, for instance, pipe your output through tr and replace all
non-printing control characters with a '|'. So if you have a program
called 'hffixtest' that outputs the FIX buffer to standard out, you
could so something like this:

# ./hffixtest | tr [:cntrl:] '|'
8=FIX.4.2|9=0051|35=0|49=AAAA|56=BBBB|34=1|52=20110130-19:14:21.056|
10=049|

Best,

James Brock
Reply all
Reply to author
Forward
0 new messages