Migrating Gecko 1.9 to 2.0 - Lot of errors - gecko

OK, after migrated to Gecko 2.0 for my XPCOM Component,
I fixed a couple of thg like below:
1. Replacing #include "nsIGenericFactory.h" to #include "mozilla/ModuleUtils.h"
2. Replacing xpcomglue_s.lib to xpcomglue_s_nomozalloc.lib
3. Adding #include "mozilla-config.h" to xpcom-config.h header file
4. And as well as remove a couple of unused header file eg: nsReadableUtils.h, nsEventQueueUtils.h, nsIExtensionManager.h
5. Replacing NS_DEFINE_STATIC_IID_ACCESSOR(IMYPROGRAM_IID) to NS_DEFINE_STATIC_IID_ACCESSOR(IMyProgram, IMYPROGRAM_IID)
Reduced from 200+ errors to 20+ now, below are a few more errors which i have no idea what is that, any expert here encounter problem like below?
error C3254: 'IMyProgram' : class contains explicit override 'kIID' but does not derive from an interface that contains the function declaration
error C2838: 'kIID' : illegal qualified name in member declaration
error C3857: 'IMyProgram::kIID': multiple template parameter lists are not allowed
error C2084: function 'void nsTraceRefcnt::LogAddRef(void *,nsrefcnt,const char *,PRUint32)' already has a body
error C2084: function 'void nsTraceRefcnt::LogRelease(void *,nsrefcnt,const char *)' already has a body
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C2146: syntax error : missing ';' before identifier 'components'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2440: 'initializing' : cannot convert from 'const char [13]' to 'int'
error C2078: too many initializers
error C2448: 'NS_IMPL_NSGETMODULE' : function-style initializer appears to be a function definition
error C2143: syntax error : missing ';' before '__stdcall'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2556: 'int MyProgramRegistration(nsIComponentManager *,nsIFile *,const char *,const char *,const int)' : overloaded function differs only by return type from 'nsresult MyProgramRegistration(nsIComponentManager *,nsIFile *,const char *,const char *,const int)'
error C2371: 'MyProgramRegistration' : redefinition; different basic types
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C3254: 'IMyProgram' : class contains explicit override 'kIID' but does not derive from an interface that contains the function declaration
error C2838: 'kIID' : illegal qualified name in member declaration
error C3857: 'IMyProgram::kIID': multiple template parameter lists are not allowed

At the very least it looks as if you are missing an NS_DECLARE_STATIC_IID_ACCESSOR(IMYPROGRAM_IID) in your interface (xpidl would have generated that for you automatically.) Some of the other errors are a bit harder to figure out without source code, but the chances are that you haven't quite managed to update your module registration code correctly.

Related

template argument deduction/substitution failure in operator<<()

I am getting the following compiler error with a class I am trying to compile with is almost identical to another class that compiles fine.
Here is the compiler error:
spell.cpp: In function ‘std::ostream& muddify::character::operator<<(std::ostream&, const muddify::character::spell&)’:
spell.cpp:11:9: error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream}’ and ‘const id_t {aka const unsigned int}’)
out <
This seems strange to me as id_t is just a typedef of unsigned int and also I have other operator overloads that are compiling fine with pretty much the same syntax. I am compiling this code under g++ version 4.9.2 on fedora 21 using the c++11 standard.
Below is my function:
std::ostream& muddify::character::operator<<(std::ostream & out,
const muddify::character::spell& s)
{
out <<s.id << "," << s.name << "," << s.desc
<< attribute_strings[unsigned(s.attribute)];
return out;
}
I am experimenting with this project with using fully qualified namespaces for improved project management so I suspect that would be part of the issue.
If you need further code or explanations I am happy to provide that.
Thanks
Paul
The namespace experiments you mentioned sound like the issue.
The error message is complaining of a missing operator in the 'muddify' namespace, not 'std'. In other words, you need to define that operator (or somehow point it at the one in namespace std).

Is there a way to use boost threads and asio in native-client?

I'm trying to port some existing code that uses boost into native-client.
I compiled boost according to the instructions here: https://code.google.com/p/naclports/wiki/InstallingSDL (with boost instead of sdl), and tried injecting some boost code into one of the examples.
I was successfully able to use a boost::shared_ptr by editing examples/api/socket/socket.cc by including the header and adding a simple test method:
#include <boost/shared_ptr.hpp>
The test method:
void ExampleInstance::test_shared_ptr() {
boost::shared_ptr<std::string> test_ptr(new std::string("hi"));
PostMessage(test_ptr->c_str());
}
Invoking this method from the constructor results in a "hi" appearing on the console when loading the page you can reach by running "make serve".
Although I'm deeply impressed that this much works, my app uses boost::thread and boost::asio, and there I ran into trouble. In pepper_34, if I add:
#include <boost/threads.hpp>
I get these compilation errors, just by including that file:
~/nacl_sdk/pepper_34/examples/api/socket$ make
CHROME_PATH is undefined, and google-chrome not found in PATH, nor /usr/bin/google-chrome.
CXX newlib/Release/socket_x86_32.o
In file included from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/thread_only.hpp:17,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/thread.hpp:12,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread.hpp:13,
from socket.cc:25:
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/pthread/thread_data.hpp: In member function 'size_t boost::thread_attributes::get_stack_size() const':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/pthread/thread_data.hpp:63: error: invalid conversion from 'const pthread_attr_t*' to 'pthread_attr_t*'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/thread/pthread/thread_data.hpp:63: error: initializing argument 1 of 'int pthread_attr_getstacksize(pthread_attr_t*, size_t*)'
make: *** [newlib/Release/socket_x86_32.o] Error 1
Likewise, if I try to include any of the basic asio elements, for instance:
#include <boost/asio/io_service.hpp>
I get these compilation errors after adding that #include line:
~/nacl_sdk/pepper_34/examples/api/socket$ make
CHROME_PATH is undefined, and google-chrome not found in PATH, nor /usr/bin/google-chrome.
CXX newlib/Release/socket_x86_32.o
In file included from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/posix_fd_set_adapter.hpp:26,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/fd_set_adapter.hpp:22,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/select_reactor.hpp:27,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/reactor.hpp:29,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/task_io_service.ipp:24,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/task_io_service.hpp:203,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/impl/io_service.hpp:71,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/io_service.hpp:767,
from socket.cc:25:
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/socket_types.hpp:283: error: 'IF_NAMESIZE' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/socket_types.hpp:304: error: 'sockaddr_un' does not name a type
In file included from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/socket_ops.hpp:326,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/select_reactor.ipp:30,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/select_reactor.hpp:212,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/reactor.hpp:29,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/task_io_service.ipp:24,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/task_io_service.hpp:203,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/impl/io_service.hpp:71,
from /home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/io_service.hpp:767,
from socket.cc:25:
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'int boost::asio::detail::socket_ops::close(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:342: error: 'FIONBIO' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'bool boost::asio::detail::socket_ops::set_user_non_blocking(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:384: error: 'FIONBIO' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'bool boost::asio::detail::socket_ops::set_internal_non_blocking(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:437: error: 'FIONBIO' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'bool boost::asio::detail::socket_ops::sockatmark(boost::asio::detail::socket_type, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:617: error: '::sockatmark' has not been declared
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'size_t boost::asio::detail::socket_ops::available(boost::asio::detail::socket_type, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:637: error: 'FIONREAD' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'void boost::asio::detail::socket_ops::init_buf(boost::asio::detail::socket_ops::buf&, void*, size_t)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:687: error: invalid use of incomplete type 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/include/newlib/sys/socket.h:304: error: forward declaration of 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:688: error: invalid use of incomplete type 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/include/newlib/sys/socket.h:304: error: forward declaration of 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'void boost::asio::detail::socket_ops::init_buf(boost::asio::detail::socket_ops::buf&, const void*, size_t)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:698: error: invalid use of incomplete type 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/include/newlib/sys/socket.h:304: error: forward declaration of 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:699: error: invalid use of incomplete type 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/include/newlib/sys/socket.h:304: error: forward declaration of 'struct iovec'
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'int boost::asio::detail::socket_ops::ioctl(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, int, boost::asio::detail::ioctl_arg_type*, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1689: error: 'FIONBIO' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'const char* boost::asio::detail::socket_ops::inet_ntop(int, const void*, char*, size_t, long unsigned int, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1974: error: 'IF_NAMESIZE' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1979: error: 'if_name' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1979: error: 'if_indextoname' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:1981: error: 'if_name' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'int boost::asio::detail::socket_ops::inet_pton(int, const char*, void*, long unsigned int*, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:2209: error: 'if_nametoindex' was not declared in this scope
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp: In function 'int boost::asio::detail::socket_ops::gethostname(char*, int, boost::system::error_code&)':
/home/jholland/nacl_sdk/pepper_34/toolchain/linux_x86_newlib/i686-nacl/usr/include/boost/asio/detail/impl/socket_ops.ipp:2251: error: '::gethostname' has not been declared
make: *** [newlib/Release/socket_x86_32.o] Error 1
(Side Note: I don't think the CHROME_PATH warning at the top is causing these errors, since I get the same warning for the examples even without my edits, but the examples still work. I imagine it's because I'm building on a vm without chrome installed (or a window manager in which to run it), since I had to use linux to build boost according to the error message the boost build process gave when I tried building it on OSX. The error messages suggest this interferes with "make run_package", but otherwise the examples run properly under "make serve", and can be tested from a different machine, using chrome to access the pages. I'm writing this question while waiting for chromium-browser to install, in hopes I can confirm that theory.)
In case it matters, I'm running Ubuntu 12.04.
My questions:
Is there a previous pepper version in which somebody has successfully used boost::asio and/or boost::threads?
Has anyone encountered this problem and discovered a workaround?
Try building the glibc build of boost instead of newlib. You can do this by running:
TOOLCHAIN=glibc make boost
from the naclports directory.
It seems that the newlib build of boost doesn't support many boost libraries:
Component configuration:
- atomic : not building
- chrono : not building
- context : not building
- coroutine : not building
- date_time : building
- exception : not building
- filesystem : not building
- graph : not building
- graph_parallel : not building
- iostreams : not building
- locale : not building
- log : not building
- math : not building
- mpi : not building
- program_options : building
- python : not building
- random : not building
- regex : not building
- serialization : not building
- signals : not building
- system : not building
- test : not building
- thread : not building
- timer : not building
- wave : not building
The glibc build seems to support many more libraries:
Component configuration:
- atomic : building
- chrono : building
- context : not building
- coroutine : not building
- date_time : building
- exception : building
- filesystem : building
- graph : building
- graph_parallel : building
- iostreams : building
- locale : building
- log : building
- math : building
- mpi : not building
- program_options : building
- python : not building
- random : building
- regex : building
- serialization : building
- signals : not building
- system : building
- test : building
- thread : building
- timer : building
- wave : building

Mono.CSharp: Evaluating math expressions

I'm trying out Mono.CSharp's evaluator.
Why does this simple script work:
int i=2,j=3;
(i*j);
whereas this gives an error:
int i=2,j=3;
i*j;
saying "(1,2): error CS0246: The type or namespace name `i' could not be found. Are you
missing a using directive or an assembly reference?"
Mono.CSharp evaluator follows C# standard grammar rules. In your second example you are actually declaring local variable based on C# grammar.
It can be rewritten to this for easier human parsing
int i = 2, j = 3;
i* j;
Compiler parses second line as another variable declaration and tries to resolve "i" as a type before it applies pointer "*" to it.

Syntax error : identifier 'String'

We received this piece of code for an assignment, and after spending a lot of time fixing the problems within, I ended up with a syntax error : identifier 'String'. Everywhere I look on the web, people are using std::string, but this is not what the code is referring to since the function is called from a C# project using a String object.
Here is the declaration :
int findWindow(String ^CaptionText,IntPtr ^%phWnd,
int %left,int %top,int %right,int %bottom);
And I have no idea how to fix that one. There are other errors such as
error C2062: type 'int' unexpected
...
error C2065: 'IntPtr' : undeclared identifier
error C2065: 'String' : undeclared identifier
...
etc.
Any help appreciated.
Should I mention that those errors have nothing to do with the assignment?
use System::String and System::IntPtr or write using namespace System;

Why am I getting this Objective-C error message: invalid conversion from 'objc_object*'

This error message had me stumped for a while:
invalid conversion from 'objc_object* to 'int'
The line in question was something like this:
int iResult = [MyUtils utilsMemberFunc:param1,param2];
It doesn't matter what the "to" type is, what is important is that you recognize that this message, in this context, is reporting that the utilsMemberFunc declaration was not found and due to Objective-C's dynamic binding it is assuming it returns an objc_object* rather than the type that utilsMemberFunc was declared to return.
So why isn't it finding the declaration? Because ',' is being used rather than ':' to separate the parameters.