my code has a warning and I don't know how to avoid it. Here is a code snippet
#include <arpa/inet.h>
int main(void) {
uint16_t portnbr=0;
uint16_t n_portnbr = htons(portnbr);
return n_portnbr;
}
Compiler:
/usr/bin/g++ -Wconversion -Wall -O2 a.cpp
Output:
a.cpp:4: warning: conversion to 'short unsigned int' from 'int' may alter its value
Is it possible to avoid the warning? No option to modify the CFLAGS.
My compiler is gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux)
This appears to be a bug in glibc. See this bug report.