I'm pretty new to this whole sass/compass/susy thing and tried to follow these intructions: http://susy.oddbird.net/demos/magic/
But I can't get the min-width for the breakpoint working.
When I add the the values to $computer and $tablet, like shown below, it runs into the following error.
Syntax error: (48em 16) is not a number for round'
on line 59 of /susy/_functions.scss, inspan-columns'
Here's my setup:
$total-columns : 4;
$column-width : 4em;
$gutter-width : 1em;
$grid-padding : $gutter-width;
// breakpoint var
$tablet: 24em 8;
$computer: 48em 16;
// test container
body {
#include container($total-columns, $tablet, $computer);
}
// test element
.test {
#include span-columns(4, $computer);
}
But if I use it this way...
.test {
#include span-columns(4, 16);
}
...everything works as expected.
Any suggestion what's wrong or has to be done?
span-columns doesn't take any breakpoint arguments like min-width (though it's an interesting idea). You need to use at-breakpoint in order to create your breakpoint, and then use span-columns inside of that:
.test {
#include at-breakpoint($computer) {
// anything inside here will happen at your 48em breakpoint, on a 16-column grid.
// no need to pass a context to span-columns when that context is the full grid.
#include span-columns(4);
}
}
Related
If I instantiate a lambda somewhere (and the compiler doesn't inline it), I can find a string showing where the lambda is located in my c++ code like this:
... ?AV<lambda_1>#?0??MyFunction#MyScopedClass#MyNamespace##SAXXZ# ...
I don't want this information in the executable, as it could give away important names of classes and functions.
All kinds of output debug information are turned off. If I use a normal function instead, the final executable doesn't have this information, so manually converting all lambdas into normal functions would "fix it". But what's the best way to handle this? Can we tell the compiler to transform lambdas into normal functions?
UPDATE: I tested with other compilers: g++ and clang. They both leave the same references. I also found another unanswered question about this Gcc - why are lambdas not stripped during release build Please don't come with the "why do you care about a few symbols anyway".
Here's some code you can test with:
#include <iostream>
#include <functional>
class MyUnscopedClass
{
public:
MyUnscopedClass(const std::function<void(int x)>& f) :
f(f)
{
}
std::function<void(int x)> f;
};
namespace MyNamespace
{
class MyScopedClass
{
public:
static void temp1(int x)
{
std::cout << x * (x + 1);
}
static void MyFunction()
{
//MyUnscopedClass obj(temp1); // no symbols
MyUnscopedClass obj([](int x) // ?AV<lambda_1>#?0??MyFunction#MyScopedClass#MyNamespace##SAXXZ#
{
std::cout << x;
});
obj.f(23);
}
};
}
int main()
{
MyNamespace::MyScopedClass::MyFunction();
}
With the help of #dxiv in the comments, I found the problematic setting.
Configuration Properties > General > C++ Language Standard
can't be, for some reason,
Preview - Features from the Latest C++ Working Draft (std:c++latest)
So I set it to the second most recent one
ISO C++17 Standard (std:c++17)
and I get a random identifier instead.
AV<lambda_f65614ace4683bbc78b79ad57f781b7f>##
I'm still curious how this identifier is chosen though.
My Qt project compiled successfully on Windows, but when I was trying to compile it on Linux it gives me all kinds of errors including the one I'm asking here:
I have a custom QGraphicsView class in my project, and it's prompted from the Qt designer. When I compiled my codes on a Linux machine, it gives me errors:
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:55: error: ISO C++ forbids declaration of ‘myGraphicsView’ with no type
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:55: error: expected ‘;’ before ‘*’ token
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h: In member function ‘void Ui_GTvalidation::setupUi(QDialog*)’:
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:173: error: ‘graphicsView’ was not declared in this scope
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:173: error: expected type-specifier before ‘myGraphicsView’
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:173: error: expected ‘;’ before ‘myGraphicsView’
Does anyone have had same issues? What's the solution?
Here is the part in ui_gtvalidation.h where it says the problems are. I'm actually not sure what part of my codes I should post to help, so let me know what you want to look at.
55:myGraphicsView *graphicsView;
173:graphicsView = new myGraphicsView(GTvalidation);
graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
myGraphicsView.h
#include <QtGui>
class myGraphicsView : public QGraphicsView{
public:
myGraphicsView(QWidget* parent = 0);
~myGraphicsView(void);
protected:
//Take over the interaction
virtual void wheelEvent(QWheelEvent* event);
};
myGraphicsView.cpp:
#include "myGraphicsView.h"
myGraphicsView::myGraphicsView(QWidget *parent) : QGraphicsView(parent){
}
myGraphicsView::~myGraphicsView(void){
}
void myGraphicsView::wheelEvent(QWheelEvent* event) {
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
// Scale the view / do the zoom
double scaleFactor = 1.15;
if(event->delta() > 0) {
// Zoom in
scale(scaleFactor, scaleFactor);
} else {
// Zooming out
scale(1.0 / scaleFactor, 1.0 / scaleFactor);
}
// Don't call superclass handler here
// as wheel is normally used for moving scrollbars
}
Your problem is actually in your gtvalidation.ui file. When you promote a widget to custom class, you need to specify include header correctly. For some reason compiler cannot find specified header in Linux. The most simple reason of this could be capitalization mismatch (as Linux filesystems are case sensitive and Windows ones are not). Check header files specified in promotion settings of your form in Designer.
So, here's my code (for simplicity I put it all into one file):
#include <afxwin.h>
#include "resource.h"
class CMainWnd : public CFrameWnd
{
};
class CApp : public CWinApp
{
public:
virtual BOOL InitInstance()
{
CMainWnd* wnd = new CMainWnd();
if (!wnd->Create(0, _T("test"))) return FALSE;
m_pMainWnd = wnd;
wnd->ShowWindow(SW_SHOW);
wnd->UpdateWindow();
return TRUE;
}
};
CApp app;
It creates simple window with default parameters and title "test". Works perfectly. But then, I want to load my window from resources, so I can put something to it. I replace:
if (!wnd->Create(0, _T("test"))) return FALSE;
with
if (!wnd->LoadFrame(IDD_CLIENTWINDOW)) return FALSE;
(IDD_CLIENTWINDOW is ID of my dialog in resources). LoadFrame returns FALSE, and program exits. There's debug message in output:
Warning: failed to load menu for CFrameWnd.
But there's no menu in dialog IDD_CLIENTWINDOW that I created. How do I load frame correctly? What am I missing?
What you are trying won't work. LoadFrame() with the ID of a dialog won't load a dialog. If you want to use a dialog, make CWnd derive from CDialog or use a view derived from CFormView. Your call to LoadFrame is failing because you don't have a menu resource with the correct ID. But, you're not really trying to do that.
I recommend you use the AppWizard to generate a new application that is either dialog based or CFormView based and see what kind of code is generated. You can look at the code to see what you really want to do.
In http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html
They give a simple TestCase but do not show how to run it (There is no main function). I've looked through their documentation and can't find how to just run a test and get text output about whether or not it succeeded. I don't want to put together a fixture or use a registry or anything.
How do I run that single test case? I.E. What is the main function that would go along with that?
I gather you were asking for a SSCCE of CppUnit. As CppUnit is a framework, so a minimal example must put minimal test structure in place -- like a TestFixture, because otherwise one could do without the whole CppUnit and just use std::assert. All this can be done in one file, say Main.cpp of the following form:
//Declaration file: MTest.h
#ifndef MTEST_H
#define MTEST_H
#include <cppunit/extensions/HelperMacros.h>
class MTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(MTest);
CPPUNIT_TEST(simpleTest);
CPPUNIT_TEST_SUITE_END();
public:
void simpleTest();
};
#endif // MTEST_H
//////////////////////////////////////
// Implementation file, e.g. MTest.cpp
#include <cppunit/config/SourcePrefix.h>
//#include "MTest.h"
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION(MTest);
// Some code to be tested.
void MTest::simpleTest() {
CPPUNIT_ASSERT_EQUAL(1, 2);
}
/////////////////////////////////////
// Main file, Main.cpp
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
int main(int argc, char* argv[])
{
CPPUNIT_NS::TextUi::TestRunner runner; //the runner
// Get the top level suite from the registry
CPPUNIT_NS::Test* suite =
CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
// Adds the test to the list of test to run
runner.addTest(suite);
// Run the test.
bool wasSucessful = runner.run();
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
}
which would need to be compiled/linked with cppunit library e.g. g++ Main.cpp ../../src/cppunit/.libs/libcppunit.a (if you happen to start 2 levels below the main directory of the library [insert the static or dynamic version of libcppunit library as is required by your environment]).
A "cleaner" examply would split the code into separate MTest (.h and .cpp, as indicated) and Main.cpp. In this case CppUnit methods from Main.cpp call methods provided by CppUnit helper macros in MTest files. They should therefore be linked together, e.g. by g++ MTest.o Main.o ../../src/cppunit/.libs/libcppunit.a.
The base class for all your test class is CppUnit::TestFixture, you can override some function like setUp and tearDown to initialize you test objects and delete them.
Consider you have a test class called MyFirstTest, to register the test functions with Cpp framework you will have to do:
CPPUNIT_TEST_SUITE(MyFirstTest);
CPPUNIT_TEST(myTestFunction);
... //any other function you want to register with appropriate macros
CPPUNIT_TEST_SUITE_END();
Also you will have to register each test class (in their respective header or cpp file)
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MyFirstTest, "YouTestName");
Once your test class is setup, you can run it. Main function will look like:
bool wasSuccessful = false;
try
{
CppUnit::TextUi::TestRunner runner;
runner.setOutputter( new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("YouTestName");
runner.addTest(registry.makeTest());
wasSuccessful = runner.run("", false);
}
catch(const std::exception& e)
{
std::cerr << e.what() << std::endl;
wasSuccessful = false;
}
If you wish to add more test classes, the main function will remain the same. You just create test class (deriving from that CppUnit::TestFixture class), register your methods and the the important step is to register you class with framework using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. The getRegistry method that is used in main function, will get all the test classes that you have registered with the framwork and executes all the methods of those classes that you have registered using CPPUNIT_TEST or any other appropriate macro.
The page you're referring to describes the whole process, including a lot of extra stuff on how you'd manually write the code in TestFixtures, then how you'd register those in TestSuites, then how you'd use the macros to write and register them, and it's very wordy. Sometimes it's better just to show people an easy example. They have this one at the very bottom of the page:
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
int main( int argc, char **argv)
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
bool wasSuccessful = runner.run( "", false );
return wasSuccessful;
}
The infrastructure is pretty simple, really. You create a test runner, then retrieve the list of registered tests, add them to the runner, have the runner run the tests, and report back to you. But yeah, it's always best to make things easy. People don't want to do hard things.
Simple but dumb solution: comment out the CPPUNIT_TEST lines you do not like.
I'm still feeling my way around C++, and am a complete ATL newbie, so I apologize if this is a basic question. I'm starting with an existing VC++ executable project that has functionality I'd like to expose as an ActiveX object (while sharing as much of the source as possible between the two projects).
I've approached this by adding an ATL project to the solution in question, and in that project have referenced all the .h and .cpp files from the executable project, added all the appropriate references, and defined all the preprocessor macros. So far so good. But I'm getting a compiler error in one file (HideDesktop.cpp). The relevant parts look like this:
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinInet.h> // Shell object uses INTERNET_MAX_URL_LENGTH (go figure)
#if _MSC_VER < 1400
#define _WIN32_IE 0x0400
#endif
#include <atlbase.h> // ATL smart pointers
#include <shlguid.h> // shell GUIDs
#include <shlobj.h> // IActiveDesktop
#include "stdhdrs.h"
struct __declspec(uuid("F490EB00-1240-11D1-9888-006097DEACF9")) IActiveDesktop;
#define PACKVERSION(major,minor) MAKELONG(minor,major)
static HRESULT EnableActiveDesktop(bool enable)
{
CoInitialize(NULL);
HRESULT hr;
CComQIPtr<IActiveDesktop, &IID_IActiveDesktop> pIActiveDesktop; // <- Problematic line (throws errors 2065 and 2275)
hr = pIActiveDesktop.CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER);
if (!SUCCEEDED(hr))
{
return hr;
}
COMPONENTSOPT opt;
opt.dwSize = sizeof(opt);
opt.fActiveDesktop = opt.fEnableComponents = enable;
hr = pIActiveDesktop->SetDesktopItemOptions(&opt, 0);
if (!SUCCEEDED(hr))
{
CoUninitialize();
// pIActiveDesktop->Release();
return hr;
}
hr = pIActiveDesktop->ApplyChanges(AD_APPLY_REFRESH);
CoUninitialize();
// pIActiveDesktop->Release();
return hr;
}
This code is throwing the following compiler errors:
error C2065: 'CComQIPtr' : undeclared identifier
error C2275: 'IActiveDesktop' : illegal use of this type as an expression
error C2065: 'pIActiveDesktop' : undeclared identifier
The two weird bits: (1) CComQIPtr is defined in atlcomcli.h, which is included in atlbase.h, which is included in HideDesktop.cpp; and (2) this file is only throwing these errors when it's referenced in my new ATL/AX project: it's not throwing them in the original executable project, even though they have basically the same preprocessor definitions. (The ATL AX project, naturally enough, defines _ATL_DLL, but I can't see where that would make a difference.)
My current workaround is to use a normal "dumb" pointer, like so:
IActiveDesktop *pIActiveDesktop;
HRESULT hr = ::CoCreateInstance(CLSID_ActiveDesktop,
NULL, // no outer unknown
CLSCTX_INPROC_SERVER,
IID_IActiveDesktop,
(void**)&pIActiveDesktop);
And that works, provided I remember to release it. But I'd rather be using the ATL smart stuff.
Any thoughts?
You may have forgotten the namespace ATL
ATL::CComQIPtr