Skip to content

Fix FreeBSD compatibility - #6270

Merged
opencv-pushbot merged 1 commit into
opencv:masterfrom
robbertkl:patch-2
Mar 16, 2016
Merged

opencv-pushbot merged 1 commit into
opencv:masterfrom
robbertkl:patch-2

Conversation

@robbertkl

Copy link
Copy Markdown
Contributor

The header <malloc.h> is deprecated / non-standard. Instead, <stdlib.h> should be used, which is defined by C99 and later.

On FreeBSD, using <malloc.h> generates an error:

In file included from ./modules/imgcodecs/src/rgbe.cpp:50:
/usr/include/malloc.h:3:2: error: "<malloc.h> has been replaced by <stdlib.h>"
#error "<malloc.h> has been replaced by <stdlib.h>"
 ^

This PR fixes the issue for FreeBSD specifically (since it currently generates an error), but it could also be fixed for all systems by removing the #ifdef altogether, since on __APPLE__, <stdlib.h> is also available. The entire include block would then become:

#include "precomp.hpp"
#include "rgbe.hpp"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

However, this should be properly tested on all platforms first, which is why I first propose this FreeBSD-only fix.

@alalek

alalek commented Mar 16, 2016

Copy link
Copy Markdown
Member

Thanks!
Could you please leave #include <stdlib.h> only (without "#ifdefs")?

@robbertkl

Copy link
Copy Markdown
Contributor Author

Just changed the commit accordingly, getting rid of <malloc.h> altogether, replacing it with <stdlib.h> for all systems.

@alalek

alalek commented Mar 16, 2016

Copy link
Copy Markdown
Member

👍

@opencv-pushbot
opencv-pushbot merged commit 81b11ee into opencv:master Mar 16, 2016
opencv-pushbot pushed a commit that referenced this pull request Mar 16, 2016
@robbertkl
robbertkl deleted the patch-2 branch April 8, 2016 13:35
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants