When compiling my FreeRTOS, my functions in string.c conflict with the built-in function 'tolower'

Hey guys When compiling my FreeRTOS, my functions in string.c conflict with the built-in function 'tolower'. Can I use a CFLAGS to resolve this error, and how can i do it? Here's my code
makefile
all: my_rtos

my_rtos: main.o string.o
gcc -o my_rtos main.o string.o

main.o: main.c
gcc -c main.c

string.o: string.c
gcc -c -Dmy_tolower=custom_tolower string.c
makefile
all: my_rtos

my_rtos: main.o string.o
gcc -o my_rtos main.o string.o

main.o: main.c
gcc -c main.c

string.o: string.c
gcc -c -Dmy_tolower=custom_tolower string.c
@Middleware & OS
2 Replies
Enthernet Code
Enthernet Code•7mo ago
Your code is accurate and should work as intended, but just in case, here's an improved version
#include <stdio.h>

void swapBytes(uint8_t *array, size_t length)
{
// Check if the array is NULL
if (array == NULL)
{
printf("Array pointer is NULL.\n");
return;
}

// Ensure the length is a multiple of 4
if (length % 4 != 0)
{
printf("Array length must be a multiple of 4.\n");
return;
}

for (size_t i = 0; i < length; i += 4)
{
// Swap the bytes within each group of 4
uint8_t temp0 = array[i];
uint8_t temp1 = array[i + 1];
uint8_t temp2 = array[i + 2];
uint8_t temp3 = array[i + 3];

array[i] = temp3;
array[i + 1] = temp2;
array[i + 2] = temp1;
array[i + 3] = temp0;
}
}
#include <stdio.h>

void swapBytes(uint8_t *array, size_t length)
{
// Check if the array is NULL
if (array == NULL)
{
printf("Array pointer is NULL.\n");
return;
}

// Ensure the length is a multiple of 4
if (length % 4 != 0)
{
printf("Array length must be a multiple of 4.\n");
return;
}

for (size_t i = 0; i < length; i += 4)
{
// Swap the bytes within each group of 4
uint8_t temp0 = array[i];
uint8_t temp1 = array[i + 1];
uint8_t temp2 = array[i + 2];
uint8_t temp3 = array[i + 3];

array[i] = temp3;
array[i + 1] = temp2;
array[i + 2] = temp1;
array[i + 3] = temp0;
}
}
Boss lady
Boss lady•7mo ago
Yes you can use CFLAGS, it should look like this 👇
CFLAGS += -Dmy_tolower=custom_tolower

all: my_rtos

my_rtos: main.o string.o
gcc $(CFLAGS) -o my_rtos main.o string.o

main.o: main.c
gcc $(CFLAGS) -c main.c

string.o: string.c
gcc $(CFLAGS) -c string.c
CFLAGS += -Dmy_tolower=custom_tolower

all: my_rtos

my_rtos: main.o string.o
gcc $(CFLAGS) -o my_rtos main.o string.o

main.o: main.c
gcc $(CFLAGS) -c main.c

string.o: string.c
gcc $(CFLAGS) -c string.c
Want results from more Discord servers?
Add your server