Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ public String getDefaultLabelPrefix() {
@Override
public String getCTypeDeclaration(DataOrganization dataOrganization) {
// NOTE: There are a variety of naming conventions for fixed-length floats
// so we will just use our name and rely on user to edit to suit there needs.
return hasLanguageDependantLength() ? null : name;
// so we will just not provide a declaration and rely on the user to declare their own.
return null;
}

private static TreeMap<Integer, AbstractFloatDataType> floatTypes; // fixed-size float types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public String getDescription() {
public Object getValue(MemBuffer buf, Settings settings, int length) {
try {
return buf.getByte(0) != 0;
}
catch (MemoryAccessException e) {
} catch (MemoryAccessException e) {
return null;
}
}
Expand Down Expand Up @@ -120,4 +119,13 @@ public AbstractIntegerDataType getOppositeSignednessDataType() {
return this;
}

private static final String EOL = System.getProperty("line.separator");

@Override
public String getCTypeDeclaration(DataOrganization dataOrganization) {
// In C++ and C23 and onwards bool is no longer a type that has to be declared first.
String declaration = super.getCTypeDeclaration(dataOrganization);
return "#if !defined(__cplusplus) && __STDC_VERSION__ < 202311L" + EOL + declaration + EOL + "#endif";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ private void writeCompositeBody(Composite composite, TaskMonitor monitor)
String compositeType = composite instanceof Structure ? "struct" : "union";

StringBuilder sb = new StringBuilder();
sb.append("#pragma pack(push, 1)").append(EOL);

sb.append(compositeType + " " + composite.getDisplayName() + " {");

String descrip = composite.getDescription();
Expand All @@ -466,7 +468,8 @@ private void writeCompositeBody(Composite composite, TaskMonitor monitor)
}

sb.append(annotator.getSuffix(composite, null));
sb.append("};");
sb.append("};").append(EOL);
sb.append("#pragma pack(pop)");

writer.write(sb.toString());
writer.write(EOL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public DataType clone(DataTypeManager dtm) {
return new FloatDataType(dtm);
}

@Override
public String getCTypeDeclaration(DataOrganization dataOrganization) {
return null; // Standard C primitive
}

@Override
public boolean hasLanguageDependantLength() {
return true;
Expand Down