Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Help to compile foo_setyear (Read 2699 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Help to compile foo_setyear

I am attempting to compile foo_setyear with Visual C++.  I was able to compile the step 1 tutorial.  I am getting the following errors and need some help.

error C2555: 'setyear::get_num_items' : overriding virtual function differs from 'menu_item_context::get_num_items' only by return type or calling convention : see declaration of 'menu_item_context'

error C2259: 'service_impl_single_t<class setyear>' : cannot instantiate abstract class due to following members : see reference to class template instantiation 'service_factory_single_t<class menu_item,class setyear>' being compiled

It would seem that the tutorial is the only thing that I can compile.  foo_abx classes is looking for mt19937int.cpp, what's that and where is it?

When I try foo_quicktag, I get many error LNK2001: unresolved external symbol from quicktag.obj, like 39 of them.

Could someone help a pittiful newb?  He would really apreciate it so much.  Thanks.

Help to compile foo_setyear

Reply #1
foo_setyear: Looks like that one will have to be updated to SDK 0.8 (0.8.1 and 0.8.2 don't really differ from it in the aspects that are causing you compile problems). Things to do:

For 'menu_item_context::get_num_items', change the return type to 'unsigned'. There are likely other methods that the compiler complains about. The general rule is, that item indices are now declared as 'unsigned' instead of 'int', so you should change that. 'menu_item_context::get_num_items' now takes an additional parameter of type 'GUID &', which you have to add to the method signature. The changes are best described by an example:
Code: [Select]
// the old way
virtual int get_num_items() {return k+1;}

virtual const char * enum_item(int n) {
   if (n == 0) return "Command 1";
   if (n == 1) return "Command 2";
   ...
   if (n == k) return "Command k+1";
   return 0;
}

virtual void context_command(int n, const ptr_list_base<metadb_handle> & data) {
   if (n == 0) {
       // perform command 1
   } else if (n == 1) {
       // perform command 2
   } ... else if (n == k) {
       // perform command k+1
   }
}

Code: [Select]
// the new way
virtual unsigned get_num_items() {return k+1;}

virtual void enum_item(unsigned n, string_base & out) {
   static const char * strings[] = {
       "Command 1", "Command 2", ..., "Command k+1"
   }
   if (n < get_num_items()) {
       out = strings[n];
   }
}

virtual void context_command(unsigned n, const ptr_list_base<metadb_handle> & data, const GUID & caller) {
   if (n == 0) {
       // perform command 1
   } else if (n == 1) {
       // perform command 2
   } ... else if (n == k) {
       // perform command k+1
   }
}

Note: The example for 'context_command' (old way) is from memory, but I hope it is correct.

For foo_quicktag, you propably have to add dependencies to foobar2000_sdk, foobar2000_component_client, and possibly foobar2000_sdk_helpers. (You can find this setting in the main menu of Visual Studio under 'Prefernces/Dependencies...'.)

You can find mt19937int.cpp on kode54's site IIRC.

Help to compile foo_setyear

Reply #2
I will give these tips a try and thank you very much.

I cannot find that file on kode54 site.  Do you know of a place that would have it?  I googled kode54 and mt19937int.cpp with no success.

Thanks again for your help.