|
Price.
(oh, and usefulness)
|
|
|
|
|
I am writing code for an embedded ARM processor and I am compiling with GNU GCC. I want to do the following:
#define PA0 GPIOA, GPIO_PIN0
#define PIN_DEF(PORT, PIN) \
GPIO_TypeDef* PORT; \
uint16_t PIN;
PIN_DEF(PA0)
However, I get an error message saying PIN_DEF requires 2 arguments but I'm only giving it 1. Does anybody know how to solve this?
|
|
|
|
|
You have defined it as PIN_DEF(PORT, PIN) , so it requires two parameters. Either change the definition, or provide the second parameter. You could try
#define PA0 (GPIOA, GPIO_PIN0)
|
|
|
|
|
The generic answer is you can use __VA_ARGS__ its used to pass variable arguments thru macros, something like this is generally how it used to feed a multi variable function
#define LOG_DEBUG(...) printf(__VA_ARGS__)
For what you are doing you pass the arguments thru two macros the first take any number of variables the second macro enforces it is using just two values.
#define PA0 GPIOA, GPIO_PIN0
#define PIN_DEF_A(A, B) \
GPIO_TypeDef* PORT; \
uint16_t PIN;
#define PIN_DEF(...) PIN_DEFA(__VA_ARGS__)
Your code doesn't make a lot of sense to me because I can't see the types. I am guessing GPIO_TypeDef* is a volatile to a 16 bit port and what you are trying to do is MACRO the output of a 16 bit value which would usually look actually like this
*((volatile uint16_t*) 0xXXXXXXXXX = 0x????;
*((volatile uint16_t*) 0x3F000000) = 0x1234;
Using the above macro form for that would be
#define PA0 0x3F000000,0x1234
#define PIN_DEFA(A, B) *((volatile uint16_t*) (A)) = (B)
#define PIN_DEF(...) PIN_DEFA(__VA_ARGS__)
PIN_DEF(PA0);
In vino veritas
modified 2-Mar-17 8:27am.
|
|
|
|
|
How to include run a program on devc++ when i have my own .h file..i have my own headerfile, but when i run my main.cpp it says, no such file or directory
|
|
|
|
|
For the header files that are not shipped with compiler as library, you need to specify where to look for. The code for,
#include "myheader.h"
Looks for in the same directory, or the directory of your project to find the header files. Remember, Dev C++ primarily is a port of GCC compiler, so every concept of GCC can be applied here similarly. GCC works fine with
* projectdirectory
|- program.c
|- myheader.h
#include "myheader.h"
int main() {
}
Also, remember that the "own headerfile" should not be written in angle brackets, they should be in quotations. For more on this please read,
http://stackoverflow.com/questions/257795/header-files-in-dev-c
http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html#Search-Path
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Please edit your question adding some more information (code snippet and indication where the error occurs, exact error message).
So I can only guess that you have something like
#include "myheader.h"
int main()
{
return 0;
}
If the error is something like "myheader.h: No such file or directory" you have to tell the compiler which directories should be searched for include files.
Because Dev-C++ uses the GCC compiler, it can be done using the command line option -I .
I don't use Dev-C++ but a quick research shows that there is a project option to specifiy additional pathes at Project - Options - Directories - Include.
|
|
|
|
|
Member 11855697 wrote: ...but when i run my main.cpp it says, no such file or directory What in the world is this supposed to mean? How do you run a .cpp file?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi
while moving my code over from VS 2012 Windows 8.1 to Windows 10 VS 2015
I got the following error
error C3861: 'RegGetValue': identifier not found
I have included WinReg.h yet intellisense points me to SHRegGetValue
|
|
|
|
|
Have you looked at Winreg.h to check that it is defined in there, and also not excluded by some #define block?
|
|
|
|
|
ForNow wrote: I have included WinReg.h yet intellisense points me to SHRegGetValue
define _WIN32_WINNT as 0x0600 or later.
|
|
|
|
|
Hello,
I am working on a windows Forms Application (C++) Programm in Visual Studio 2015.
I have figured out how to open a file. And read from it.
But what I can't figure out is how to only read the second line or the second row from my file (.cvs file).
What I am looking for is the syntax to use instead of RealAllText.
I looked up the Objectkatalog. But I can't get "ReadLine" to work.
My code is posted below.
I really hope someone can help me
Kind regards
private: System::Void button6_Click_1(System::Object^ sender, System::EventArgs^ e) {
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
if( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
String^ strfilename = openFileDialog1->InitialDirectory + openFileDialog1->FileName;
String^ Readfile = File::ReadAllText(strfilename);
Malz4->Text = Readfile;
myStream->Close();
}
}
|
|
|
|
|
|
Hey, thanks for your help but I still can't get my code to work.
I typed in your suggestion but maybe I am doing a sytax error?
I am a beginner so that might be the case haha
And how would I get the second column out?
|
|
|
|
|
Without seeing your code it is impossible to comment.
|
|
|
|
|
If ReadAllText() returns a sequence, could you then call First() twice on that sequence?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I am using a bitmap for a dialog background, which works fine.
I am also doing some GDI drawing on top of the bitmap.
The problem is updating the GDI drawing causes the bitmap to blink. On a slower computer this may be a major annoyance.
The bitmap is loaded in the OnPaint() message handler, where the GDI drawing is also performed and updated.
I have tried loading the bitmap image only once, but when the GDI drawing is updated, the bitmap background is erased and not replaced.
Is it possible to load the bitmap once, and not have it erased in OnPaint() when the GDI drawing is updated?
|
|
|
|
|
Have you tried to not call default OnEraseBackground ?
Something like that:
BOOL CYourDlg::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
|
|
|
|
|
Yes, I found that in a book last night, and it works! Thank you
|
|
|
|
|
I am trying to order a set of buttons in a ribbon bar.
The code below should create a ribbon with the layout (sorry bad paint drawing)
See expected layout : Ribbon Layout - Album on Imgur
But I get this : Ribbon Layout - Album on Imgur
Where the 3 buttons (zoom window, zoom in and zoom out) are placed on the right of the gallery.
I am not certain what I do wrong here, everything looks nicely coded !
Any insights, help, hints or tips ?
m_wndRibbonBar.Create(this);
CMFCRibbonCategory* category = m_wndRibbonBar.AddCategory(_TEXT("Test"), ITB_HOME_CATEGORY_16X16, ITB_HOME_CATEGORY_32X32 );
CMFCRibbonPanel* panel = category->AddPanel(_TEXT("Stuff"));
panel->Add(new CMFCRibbonButton(IDM_VIEW_ZOOM_ALL, _T("Zoom All"), 0, 0, FALSE));
panel->AddSeparator();
panel->Add(new CMFCRibbonButton(IDM_VIEW_ZOOM_WINDOW, _T("Zoom Window"), 1, -1, FALSE));
panel->Add(new CMFCRibbonButton(IDM_VIEW_ZOOM_IN, _T("Zoom In"), 26, -1, FALSE));
panel->Add(new CMFCRibbonButton(IDM_VIEW_ZOOM_OUT, _T("Zoom Out"), 27, -1, FALSE));
panel->AddSeparator();
CMFCRibbonGallery* viewRibbonGallery = new CMFCRibbonGallery(ID_HOME_VIEWS_RIBBON_BUTTON, _T("Views"), 7, 1, IDB_HOME_VIEWS_PALETTE_32X32, 32);
panel->Add(viewRibbonGallery);
panel->AddSeparator();
CMFCRibbonButtonsGroup* viewTypeGroup = new CMFCRibbonButtonsGroup;
viewTypeGroup->AddButton(new CMFCRibbonButton(IDM_VIEW_MODE_NORMAL, _TEXT("Normal"), 20, FALSE));
viewTypeGroup->AddButton(new CMFCRibbonButton(IDM_VIEW_MODE_SHADED, _TEXT("Shaded"), 21, FALSE));
viewTypeGroup->AddButton(new CMFCRibbonButton(IDM_VIEW_MODE_WIREFRAME, _TEXT("Wireframe"), 22, FALSE));
panel->Add(viewTypeGroup);
CMFCRibbonButtonsGroup* wireFrameTypeGroup = new CMFCRibbonButtonsGroup;
wireFrameTypeGroup->AddButton(new CMFCRibbonButton(IDM_VIEW_WIREFRAME_BOUNDARY, _TEXT("Boundary"), 23, FALSE));
wireFrameTypeGroup->AddButton(new CMFCRibbonButton(IDM_VIEW_WIREFRAME_ISOLINE, _TEXT("Isoline"), 24, FALSE));
wireFrameTypeGroup->AddButton(new CMFCRibbonButton(IDM_VIEW_WIREFRAME_MESH, _TEXT("Mesh"), 25, FALSE));
panel->Add(wireFrameTypeGroup);
I'd rather be phishing!
|
|
|
|
|
Hi everyone,
I have worked with basic knowledge of C++. I am struggling to understand how to develop an android app with the Visual C++ platform.I have installed all necessary software yet the sample codes look different from what I have learned. I really need advice, reference sheets or any related stuff that would help me on this path. Thank you.
|
|
|
|
|
|
I am trying to parse an expression like this:
F( 1, 2, 3)
and extract 1, 2 and 3 as a strings.
My test grammar and program parse properly, but the output is not "nice",
In the start, limit and increment variable contain strings like "\x1", "\x2" and "\x3"
This is part of my grammar. (the pre tag does not work "good" here)
I also tried to read the numerical value as an int and use a boost::variant to hold either an int or std:wstring, but that did not work.
Any thoughts, hints or tips ?
Thanks.
More friendly code here http://pastebin.com/2mmK9gns
struct RangeResult
{
std::wstring start;
std::wstring limit;
std::wstring increment;
};
BOOST_FUSION_ADAPT_STRUCT(
RangeGrammar::RangeResult,
(std::wstring, start)
(std::wstring, limit)
(std::wstring, increment)
)
template <typename Iterator>
struct range_parser : boost::spirit::qi::grammar<Iterator, RangeResult(), iso8859_1::space_type>
{
range_parser() : range_parser::base_type(start)
{
using qi::lit;
using qi::lexeme;
using qi::int_;
using iso8859_1::char_;
using iso8859_1::digit;
variable_string %= lexeme["$(" >> +(char_ - ")") >> ")"];
node = (int_ | variable_string);
start %=
lit("_RANGE")
<blockquote class="quote">
<blockquote class="quote">
'('
node >> ',' >> node >> ',' >> node
")_"
;
</blockquote>
</blockquote>
debug(variable_string);
debug(start);
}
qi::rule<Iterator, std::wstring(), iso8859_1::space_type> variable_string;
qi::rule<Iterator, std::wstring(), iso8859_1::space_type> node;
qi::rule<Iterator, RangeResult(), iso8859_1::space_type> start;
};
My test program:
void TestRangeGrammar()
{
using boost::spirit::iso8859_1::space;
typedef std::wstring::const_iterator iterator_type;
typedef RangeGrammar::range_parser<iterator_type> range_parser;
<pre>
range_parser grammar;
std::array< std::wstring, 1 > testStrings =
{{
_TEXT("_RANGE(1, 2, 3 )_")
}};
for (auto str : testStrings)
{
std::wstring::const_iterator iter = str.begin();
std::wstring::const_iterator end = str.end();
RangeGrammar::RangeResult emp;
bool r = phrase_parse(iter, end, grammar, space, emp);
if (r)
{
std::wcout << _TEXT("-------------------------\n");
std::wcout << _TEXT("Range Parsing succeeded\n");
std::wcout << _TEXT("Start: ") << emp.start << std::endl;
std::wcout << _TEXT("Start: ") << emp.limit << std::endl;
std::wcout << _TEXT("Start: ") << emp.increment << std::endl;
std::wcout << _TEXT("\n-------------------------\n");
}
else
{
std::wcout << _TEXT("-------------------------\n");
std::wcout << _TEXT("Range Parsing failed\n");
std::wcout << str << std::endl;
std::wcout << _TEXT("-------------------------\n");
}
}
}
I'd rather be phishing!
|
|
|
|
|
Hi, I'm still a beginner in coding, I need block cipher source code for my research paper where I need to get the run time for mode of operation, I already find a lot of source code but none of it seems working, example the crypto++ . I don't even know how to set it up. if anyone could help me at least on how to run the crypto++ . and fyi im using a quad core processor laptop, windows 10 and visual studio 2015. :(( :(( :((
this is the crypto++ I downloaded
|
|
|
|
|
|