Skip to content

Add required header file and namespace element instead add all. #7864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions events/EventQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/
#include "events/EventQueue.h"

#include "events/mbed_events.h"
#include "mbed.h"

using mbed::Callback;

namespace events {

EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer)
{
Expand Down Expand Up @@ -77,3 +78,4 @@ void EventQueue::chain(EventQueue *target)
equeue_chain(&_equeue, 0);
}
}
}
12 changes: 11 additions & 1 deletion events/equeue/equeue_mbed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
#if defined(EQUEUE_PLATFORM_MBED)

#include <stdbool.h>
#include "mbed.h"
#include <string.h>
#include "platform/mbed_critical.h"
#include "drivers/Timer.h"
#include "drivers/Ticker.h"
#include "drivers/Timeout.h"
#include "drivers/LowPowerTimeout.h"
#include "drivers/LowPowerTicker.h"
#include "drivers/LowPowerTimer.h"

using namespace mbed;

// Ticker operations
#if MBED_CONF_RTOS_PRESENT
Expand All @@ -33,6 +42,7 @@ unsigned equeue_tick() {
#else

#if MBED_CONF_EVENTS_USE_LOWPOWER_TIMER_TICKER

#define ALIAS_TIMER LowPowerTimer
#define ALIAS_TICKER LowPowerTicker
#define ALIAS_TIMEOUT LowPowerTimeout
Expand Down
6 changes: 5 additions & 1 deletion events/mbed_shared_queues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/

#include "events/mbed_shared_queues.h"
#include "mbed.h"

#ifdef MBED_CONF_RTOS_PRESENT
#include "rtos/Thread.h"
using rtos::Thread;
#endif

using namespace events;

Expand Down
22 changes: 14 additions & 8 deletions platform/ATCmdParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include "ATCmdParser.h"
#include "mbed_poll.h"
#include "mbed_debug.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef LF
#undef LF
Expand All @@ -36,6 +39,8 @@
#define CR 13
#endif

namespace mbed {

// getc/putc handling with timeouts
int ATCmdParser::putc(char c)
{
Expand Down Expand Up @@ -102,7 +107,7 @@ int ATCmdParser::read(char *data, int size)


// printf/scanf handling
int ATCmdParser::vprintf(const char *format, va_list args)
int ATCmdParser::vprintf(const char *format, std::va_list args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::vaargs types are in #include <cstdarg> How is it included ?

Copy link
Author

@deepikabhavnani deepikabhavnani Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{

if (vsprintf(_buffer, format, args) < 0) {
Expand All @@ -118,7 +123,7 @@ int ATCmdParser::vprintf(const char *format, va_list args)
return i;
}

int ATCmdParser::vscanf(const char *format, va_list args)
int ATCmdParser::vscanf(const char *format, std::va_list args)
{
// Since format is const, we need to copy it into our buffer to
// add the line's null terminator and clobber value-matches with asterisks.
Expand Down Expand Up @@ -181,7 +186,7 @@ int ATCmdParser::vscanf(const char *format, va_list args)


// Command parsing with line handling
bool ATCmdParser::vsend(const char *command, va_list args)
bool ATCmdParser::vsend(const char *command, std::va_list args)
{
// Create and send command
if (vsprintf(_buffer, command, args) < 0) {
Expand All @@ -205,7 +210,7 @@ bool ATCmdParser::vsend(const char *command, va_list args)
return true;
}

bool ATCmdParser::vrecv(const char *response, va_list args)
bool ATCmdParser::vrecv(const char *response, std::va_list args)
{
restart:
_aborted = false;
Expand Down Expand Up @@ -331,7 +336,7 @@ bool ATCmdParser::vrecv(const char *response, va_list args)
// Mapping to vararg functions
int ATCmdParser::printf(const char *format, ...)
{
va_list args;
std::va_list args;
va_start(args, format);
int res = vprintf(format, args);
va_end(args);
Expand All @@ -340,7 +345,7 @@ int ATCmdParser::printf(const char *format, ...)

int ATCmdParser::scanf(const char *format, ...)
{
va_list args;
std::va_list args;
va_start(args, format);
int res = vscanf(format, args);
va_end(args);
Expand All @@ -349,7 +354,7 @@ int ATCmdParser::scanf(const char *format, ...)

bool ATCmdParser::send(const char *command, ...)
{
va_list args;
std::va_list args;
va_start(args, command);
bool res = vsend(command, args);
va_end(args);
Expand All @@ -358,7 +363,7 @@ bool ATCmdParser::send(const char *command, ...)

bool ATCmdParser::recv(const char *response, ...)
{
va_list args;
std::va_list args;
va_start(args, response);
bool res = vrecv(response, args);
va_end(args);
Expand Down Expand Up @@ -431,4 +436,5 @@ bool ATCmdParser::process_oob()
}
}

}

11 changes: 6 additions & 5 deletions platform/ATCmdParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
#ifndef MBED_ATCMDPARSER_H
#define MBED_ATCMDPARSER_H

#include "mbed.h"
#include <cstdarg>
#include "Callback.h"
#include "NonCopyable.h"
#include "FileHandle.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest build points to this file, seems like some includes are missing and build fails

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: std namespace was missing


namespace mbed {

Expand Down Expand Up @@ -202,7 +203,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
*/
bool send(const char *command, ...) MBED_PRINTF_METHOD(1, 2);

bool vsend(const char *command, va_list args);
bool vsend(const char *command, std::va_list args);

/**
* Receive an AT response
Expand All @@ -220,7 +221,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
*/
bool recv(const char *response, ...) MBED_SCANF_METHOD(1, 2);

bool vrecv(const char *response, va_list args);
bool vrecv(const char *response, std::va_list args);

/**
* Write a single byte to the underlying stream
Expand Down Expand Up @@ -265,7 +266,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
*/
int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2);

int vprintf(const char *format, va_list args);
int vprintf(const char *format, std::va_list args);

/**
* Direct scanf on underlying stream
Expand All @@ -277,7 +278,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
*/
int scanf(const char *format, ...) MBED_SCANF_METHOD(1, 2);

int vscanf(const char *format, va_list args);
int vscanf(const char *format, std::va_list args);

/**
* Attach a callback for out-of-band data
Expand Down
3 changes: 2 additions & 1 deletion platform/FileSystemHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

#include "mbed.h"
#include "FileSystemHandle.h"
#include <errno.h>

namespace mbed {
int FileSystemHandle::open(DirHandle **dir, const char *path)
{
return -ENOSYS;
Expand Down Expand Up @@ -47,3 +47,4 @@ int FileSystemHandle::statvfs(const char *path, struct statvfs *buf)
{
return -ENOSYS;
}
}
2 changes: 1 addition & 1 deletion platform/mbed_wait_api_rtos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "platform/mbed_wait_api.h"
#include "hal/us_ticker_api.h"
#include "rtos/rtos.h"
#include "rtos/ThisThread.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_power_mgmt.h"

Expand Down
4 changes: 2 additions & 2 deletions rtos/Kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* SOFTWARE.
*/

#include "cmsis_os2.h"
#include "rtos/Kernel.h"

#include "mbed.h"
#include "rtos/rtos_idle.h"
#include "rtos/rtos_handlers.h"
#include "platform/mbed_critical.h"

namespace rtos {

Expand Down
8 changes: 4 additions & 4 deletions rtos/RtosTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
* SOFTWARE.
*/
#include "rtos/RtosTimer.h"
#include "platform/Callback.h"
#include "platform/mbed_error.h"
#include "platform/mbed_assert.h"

#include <string.h>

#include "mbed.h"
#include "platform/mbed_error.h"

namespace rtos {

void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
Expand All @@ -34,7 +34,7 @@ void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
osTimerAttr_t attr = { 0 };
attr.cb_mem = &_obj_mem;
attr.cb_size = sizeof(_obj_mem);
_id = osTimerNew((void (*)(void *))Callback<void()>::thunk, type, &_function, &attr);
_id = osTimerNew((void (*)(void *))mbed::Callback<void()>::thunk, type, &_function, &attr);
MBED_ASSERT(_id);
}

Expand Down
4 changes: 2 additions & 2 deletions rtos/ThisThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#define __STDC_LIMIT_MACROS
#include "rtos/ThisThread.h"

#include "mbed.h"
#include "rtos/Kernel.h"
#include "rtos/rtos_idle.h"
#include "mbed_assert.h"
#include "platform/mbed_assert.h"

namespace rtos {

Expand Down
9 changes: 4 additions & 5 deletions rtos/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
*/
#include "rtos/Thread.h"
#include "rtos/ThisThread.h"

#include "mbed.h"
#include "rtos/rtos_idle.h"
#include "rtos/rtos_handlers.h"
#include "mbed_assert.h"
#include "platform/mbed_assert.h"
#include "platform/mbed_error.h"

#define ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
MBED_STATIC_ASSERT(ALIGN_UP(0, 8) == 0, "ALIGN_UP macro error");
Expand Down Expand Up @@ -68,7 +67,7 @@ void Thread::constructor(osPriority priority,
constructor(MBED_TZ_DEFAULT_ACCESS, priority, stack_size, stack_mem, name);
}

void Thread::constructor(Callback<void()> task,
void Thread::constructor(mbed::Callback<void()> task,
osPriority priority, uint32_t stack_size, unsigned char *stack_mem, const char *name)
{
constructor(MBED_TZ_DEFAULT_ACCESS, priority, stack_size, stack_mem, name);
Expand All @@ -87,7 +86,7 @@ void Thread::constructor(Callback<void()> task,
}
}

osStatus Thread::start(Callback<void()> task)
osStatus Thread::start(mbed::Callback<void()> task)
{
_mutex.lock();

Expand Down