我有两个简单的文件:
runner.cpp:
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE Main
#include <boost/test/unit_test.hpp>
Run Code Online (Sandbox Code Playgroud)
和test1.cpp:
#define BOOST_TEST_DYN_LINK
#ifdef STAND_ALONE
# define BOOST_TEST_MODULE Main
#endif
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE( Foo)
BOOST_AUTO_TEST_CASE( TestSomething )
{
BOOST_CHECK( true );
}
BOOST_AUTO_TEST_SUITE_END()
Run Code Online (Sandbox Code Playgroud)
要编译,我正在使用:
$ g++ -I/e/code/boost_1_52_0 -o runner -lboost_unit_test_framework runner.cpp test1.cpp
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text+0x8c): multiple definition of `main'
c:/pdev/mingw/bin/../lib/gcc/i686-pc-mingw32/4.7.2/../../../libboost_unit_test_framework.a(unit_test_main.o):unit_test_main.cpp:(.text.startup+0x0): first defined here
c:/pdev/mingw/bin/../lib/gcc/i686-pc-mingw32/4.7.2/../../../libboost_unit_test_framework.a(unit_test_main.o):unit_test_main.cpp:(.text.startup+0x14): undefined reference to `init_unit_test_suite(int, char**)'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text+0x52): undefined reference to `_imp___ZN5boost9unit_test9framework17master_test_suiteEv'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text+0xb0): undefined reference to `_imp___ZN5boost9unit_test14unit_test_mainEPFbvEiPPc'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text$_ZN5boost9unit_test13test_observerD2Ev[__ZN5boost9unit_test13test_observerD2Ev]+0xe): undefined reference to `_imp___ZTVN5boost9unit_test13test_observerE'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text$_ZN5boost9unit_test13test_observerC2Ev[__ZN5boost9unit_test13test_observerC2Ev]+0xe): undefined reference to `_imp___ZTVN5boost9unit_test13test_observerE'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text$_ZN5boost9unit_test15unit_test_log_tC1Ev[__ZN5boost9unit_test15unit_test_log_tC1Ev]+0x22): undefined reference …
Run Code Online (Sandbox Code Playgroud) 我有div(#child
),不会扩展到其父级(#parent
)的整个高度。我已经设定了html
和的高度body
。如果将父级的高度设置为100%,但我希望父级具有最小高度,并且子级可以扩展到父级的全高,则它可以工作。
HTML:
<html>
<body>
<div id="parent">
<div id="child">
<p>This area should be have the same height as it's parent.</p>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
CSS:
html, body, header, h1, p { margin: 0; padding: 0; }
html { background-color: #DDD; height: 100%; }
body { background-color: #DAA; height: 100%; }
#parent {
min-height: 70%;
height: auto !important;
height: 70%;
background-color: #AAD;
}
#child {
height: 100%; /* why isn't this working ? */ …
Run Code Online (Sandbox Code Playgroud) 刚开始使用Silex并遇到一些问题.
下载的脂肪压缩文件,解压成wamp
的www
文件夹中.所以,这是C:\wamp\www\fat-silex\web\index.php
:
<?php
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/hello', function() {
return 'Hello!';
});
$app->run();
Run Code Online (Sandbox Code Playgroud)
问题是我正在获取Apache的404 http://localhost/fat-silex/web/hello
,以及任何URL,除了localhost/fat-silex/web
我正在获得Silex'es 404(正如预期的那样).我猜这些请求直接发送到Apache,并且不会被Silex路由.看起来问题可以用.htaccess
文件解决,所以我在官方文档中建议添加了这个:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /fat-silex
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
但是,它似乎没有任何影响.
我有以下C++代码:
#include <iostream>
#include <string>
using namespace std;
class Surface
{
public:
virtual void draw();
protected:
int x,y;
};
class Control: public Surface
{
public:
Control(): x(10), y(10), name("control") { cout << "Control constructor" << endl; }
void draw() {}
protected:
string name;
};
class Label: public Control
{
public:
Label(): x(10), y(10), name("label"), text("label") { cout << "Label constructor" << endl; }
void draw() { cout << "drawing a label" << endl; }
protected:
string text;
};
int main(int …
Run Code Online (Sandbox Code Playgroud)