int fct2 (int dummy, ...) { va_list argp; int ret = dummy; va_start (argp, dummy); ret += fct1 (argp, SZ_ARGS); va_end (argp); return ret; }
int main(void) { char b; int cnt = 0; printf("\n%5s%5s%5s%5s%5s%5s%7s%7s%11s\n\n", "Cnt", "b1", "b2", "b3", "b4", "b5", "fct1", "fct2", "majority"); for (b = 0; b < 32; ++b) { printf("%5d%5d%5d%5d%5d%5d%6d%7d%9d\n", ++cnt, b_val(5, b), b_val(4, b), b_val(3, b), b_val(2, b), b_val(1, b), fct1(b), fct2(b), majority(b)); } putchar('\n'); return 0; }
int main(int argv, char *args[]) { if (argv < 2) { std::cout << " I want name of library\n"; return -1; } QString filename = QString("%1").arg(args[1]); std::cout << "Filename = [" << filename.toStdString() << "]\n"; if (QLibrary::isLibrary(filename)) { std::cout << " is not Library\n"; return -2; } else { std::cout << " is Library\n"; } QLibrary lib(filename, "1.0.0"); if (lib.load()) { std::cout << "lib is loaded\n"; } else { std::cout << "lib is NOT loaded\n" << lib.errorString().toStdString() << "\n"; return -3; } typedef QString (*Fct1) (const QString&); typedef QString (*Fct2) (const QString&); Fct1 fct1 = (Fct1)(lib.resolve("oddUpper")); if (fct1) { std::cout << fct1("hello !!!! ").toStdString() << "\n"; } else { std::cout << "nicht\n"; } Fct2 fct2 = (Fct2)(lib.resolve("oddUpper2")); if (fct2) { std::cout << fct2("hello !!!! ").toStdString() << "\n"; } else { std::cout << "nicht\n"; } /* QApplication app(argv, args); // QDir pluginsDir = QDir("./"); QString filename = QDir::currentPath() + "/libtestPlugin.so"; // QString filename = "testPlugin.so"; QFile file(filename); std::cout << "[" << filename.toStdString() << "]\n"; if (!file.exists()) std::cout << "file not found\n"; QPluginLoader loader( filename ); if ( !loader.load() ) { qWarning( "This is not Qt plugin or plugin not match out Qt Libraries" ); return -1; } MyInterface * i = qobject_cast<MyInterface*>( loader.instance() ); if ( !i ) { qWarning( "This is not plugin for interface MyInterface" ); return -2; } QString text = i->doSomething( 123 ); // text = "123" std::cout << text.toStdString(); * */ return 0; }
int main(void){ int array[5]; fct1(array); fct2(array); return 0; }