Skip to content

Commit fdcc1e3

Browse files
committed
Merge pull request #239 from neilt6/master
Changed error(...) to a weak function
2 parents 8a97a64 + e57e69c commit fdcc1e3

File tree

9 files changed

+49
-7
lines changed

9 files changed

+49
-7
lines changed

libraries/mbed/api/error.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@
5353
* #endcode
5454
*/
5555

56-
#include <stdlib.h>
57-
#include "device.h"
56+
#include "toolchain.h"
5857

59-
#if DEVICE_STDIO_MESSAGES
60-
#include <stdio.h>
61-
#define error(...) (fprintf(stderr, __VA_ARGS__), exit(1))
62-
#else
63-
#define error(...) (exit(1))
58+
#ifdef __cplusplus
59+
extern "C" {
60+
#endif
61+
62+
void error(const char* format, ...);
63+
64+
#ifdef __cplusplus
65+
}
6466
#endif
6567

6668
#endif

libraries/mbed/common/error.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include <stdlib.h>
17+
#include <stdarg.h>
18+
#include "device.h"
19+
#include "toolchain.h"
20+
#if DEVICE_STDIO_MESSAGES
21+
#include <stdio.h>
22+
#endif
23+
24+
WEAK void error(const char* format, ...);
25+
WEAK void error(const char* format, ...) {
26+
#if DEVICE_STDIO_MESSAGES
27+
va_list arg;
28+
va_start(arg, format);
29+
vfprintf(stderr, format, arg);
30+
va_end(arg);
31+
#endif
32+
exit(1);
33+
}

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// math.h required for floating point operations for baud rate calculation
1717
#include <math.h>
1818
#include <string.h>
19+
#include <stdlib.h>
1920

2021
#include "serial_api.h"
2122
#include "cmsis.h"

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/serial_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// math.h required for floating point operations for baud rate calculation
1717
#include <math.h>
1818
#include <string.h>
19+
#include <stdlib.h>
1920

2021
#include "serial_api.h"
2122
#include "cmsis.h"

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC13XX/serial_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// math.h required for floating point operations for baud rate calculation
1717
#include <math.h>
1818
#include <string.h>
19+
#include <stdlib.h>
1920

2021
#include "serial_api.h"
2122
#include "cmsis.h"

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// math.h required for floating point operations for baud rate calculation
1717
#include <math.h>
1818
#include <string.h>
19+
#include <stdlib.h>
1920

2021
#include "serial_api.h"
2122
#include "cmsis.h"

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC23XX/serial_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// math.h required for floating point operations for baud rate calculation
1717
#include <math.h>
1818
#include <string.h>
19+
#include <stdlib.h>
1920

2021
#include "serial_api.h"
2122
#include "cmsis.h"

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/serial_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// math.h required for floating point operations for baud rate calculation
1717
#include <math.h>
1818
#include <string.h>
19+
#include <stdlib.h>
1920

2021
#include "serial_api.h"
2122
#include "cmsis.h"

libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/serial_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// math.h required for floating point operations for baud rate calculation
1919
#include <math.h>
2020
#include <string.h>
21+
#include <stdlib.h>
2122

2223
#include "serial_api.h"
2324
#include "cmsis.h"

0 commit comments

Comments
 (0)