error: expected primary-expression before ',' token

my code is:

#include <stdint.h>
#include <stdio.h>

template<typename SIZE_T>class mybody_t {
uint8_t _space[128];
public:
template<typename HEAD_T>inline HEAD_T *head(void) { return (HEAD_T *)_space; }
template<typename HEAD_T, typename NODE_T>inline NODE_T *head_at(size_t idx)
{ return (NODE_T *)(_space + sizeof(HEAD_T) + sizeof(NODE_T) *idx); }

template<typename NODE_T>inline unsigned diff(NODE_T *ptr)
{ return (unsigned)((uint8_t *)ptr - _space); }
};
template<typename SIZE_T, class HEADER_BODY_T>class myheader_t {
mybody_t<SIZE_T> *_body;
public:
inline uint32_t *magic(void) { return _body->head<uint32_t>(); }
inline HEADER_BODY_T *body(void) { return _body->head_at<uint32_t, HEADER_BODY_T>(0); }
};

int
main(void)
{
mybody_t<uint16_t> mybody;
uint64_t *ptr0 = mybody.head_at<uint16_t, uint64_t>(0);
uint64_t *ptr1 = mybody.head_at<uint16_t, uint64_t>(1);
printf("%u, %u\n", mybody.diff(ptr0), mybody.diff(ptr1));
return 0;
}

compiled by g++, it report:

g++ -o tst-functemp.o -c -g -Wall -std=c++11 tst-functemp.cpp
tst-functemp.cpp: In member function 'uint32_t* myheader_t<SIZE_T, HEADER_BODY_T>::magic()':
tst-functemp.cpp:17:64: error: expected primary-expression before '>' token
inline uint32_t *magic(void) { return _body->head <uint32_t>(); }
^
tst-functemp.cpp:17:66: error: expected primary-expression before ')' token
inline uint32_t *magic(void) { return _body->head <uint32_t>(); }
^
tst-functemp.cpp: In member function 'HEADER_BODY_T* myheader_t<SIZE_T, HEADER_BODY_T>::body()':
tst-functemp.cpp:18:71: error: expected primary-expression before ',' token
inline HEADER_BODY_T *body(void) { return _body->head_at <uint32_t, HEADER_BODY_T>(0); }
^
tst-functemp.cpp:18:86: error: expected primary-expression before '>' token
inline HEADER_BODY_T *body(void) { return _body->head_at <uint32_t, HEADER_BODY_T>(0); }

what's wrong with my code?

You got an extra bracket:

1
2
3
inline uint32_t *magic(void) { return _body->head<uint32_t>(); }
inline HEADER_BODY_T *body(void) { return _body->head_at<uint32_t, HEADER_BODY_T>(0); }
}; //here 
Topic archived. No new replies allowed.