0

I'm getting this error error C2143: syntax error : missing ';' before ''template<'' when trying to build a project. So if anyone could please advise how I can solve this error.

Tak
  • 3,536
  • 11
  • 51
  • 93
  • 3
    Tip: to solve problems like this, reduce it to a minimum case that still gives the same problem. Then it may be more obvious. – M.M Jul 14 '14 at 06:41
  • 3
    Posting tip: when posting "error on line 90", actually indicate which line of your code is line 90. – M.M Jul 14 '14 at 06:41
  • 1
    I'm guessing it should be `template PCL_EXPORTS bool` . However this is still fishy, as template functions must be fully visible at the point of instantiation. Is this the actual file from PCL or has someone edited in the template bit? – M.M Jul 14 '14 at 06:47
  • @MattMcNabb Thanks Matt for your comments, I've modified the question to specify the line of error. I'll try your suggestion and let you know. I'm not sure which template you are asking about? I'm sorry if my question seems trivial. Thanks alot again Matt – Tak Jul 14 '14 at 06:52
  • @MattMcNabb thanks Matt!!! this did it. So if you could please post it as an answer to accept it. Many Thanks again – Tak Jul 14 '14 at 06:55
  • mmmm :) , this is weird! because doing your suggestion removed those errors but other linking errors appeared. I'm not sure whether they are because of that modification? – Tak Jul 14 '14 at 06:57
  • It's best to drop PCL_EXPORTS from all templates. You cannot export a template anyway, it does not exist in the compiled library, only in headers. (You can export a template specialization). Another problem here is some of the function templates don't have bodies. See http://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file – n. m. could be an AI Jul 14 '14 at 07:12
  • In its current form, with the code deleted from the question, this post is unlikely to help future readers. – Adrian McCarthy Jul 15 '14 at 17:11

1 Answers1

2

The line with

PCL_EXPORTS bool template <typename Scalar> 

should be

template <typename Scalar> PCL_EXPORTS bool

Probably PCL_EXPORTS is __declspec(dllexport) and typically these things have to come after the template<...>.

I checked and this template is not present in a fresh download of the latest PCL, so I'm guessing it is a fork that somebody has made and it relied on properties of whichever compiler they were using.

Generally speaking, doing dllexport on a function template is a can of worms. But since you say this change appears to fix it, maybe the worms are staying in the can for now!

M.M
  • 138,810
  • 21
  • 208
  • 365
  • +1 but from the *but other linking errors appeared* comment above, it appears the worms didn't stay in the can for too long :) – Praetorian Jul 14 '14 at 07:09